Skip to content

Commit ece3750

Browse files
Glenn SnyderEric Lei
authored andcommitted
incrementing version and adding couple of unit tests for get_codelocations
1 parent 978c43d commit ece3750

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

blackduck/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION = (0, 0, 39)
1+
VERSION = (0, 0, 40)
22

33
__version__ = '.'.join(map(str, VERSION))

test/test_hub_rest_api_python.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,3 +470,29 @@ def test_validated_json_fails_with_invalid_json_str(mock_hub_instance):
470470
with pytest.raises(JSONDecodeError) as e_info:
471471
validated_json = mock_hub_instance._validated_json_data('invalid json')
472472

473+
@pytest.fixture()
474+
def code_locations(requests_mock, shared_datadir):
475+
data = json.load((shared_datadir / 'code_locations.json').open())
476+
requests_mock.get(
477+
"{}/api/codelocations?limit=100".format(fake_hub_host),
478+
json = data
479+
)
480+
yield data
481+
482+
def test_get_codelocations_all(mock_hub_instance, code_locations):
483+
code_locs = mock_hub_instance.get_codelocations()
484+
485+
assert code_locs == code_locations
486+
487+
def test_get_codelocations_unmapped(mock_hub_instance, code_locations):
488+
code_locs = mock_hub_instance.get_codelocations(unmapped=True)
489+
490+
assert code_locs != code_locations
491+
492+
expected_data = copy.deepcopy(code_locations)
493+
expected_data['items'] = [cl for cl in code_locations['items'] if 'mappedProjectVersion' not in cl]
494+
expected_data['totalCount'] = len(expected_data['items'])
495+
496+
assert code_locs == expected_data
497+
498+

0 commit comments

Comments
 (0)