-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sw360_objects): better __repr__ and __str__
This allows for easy copy'n'pasting of an object in interactive sessions plus nicer print output.
- Loading branch information
Showing
4 changed files
with
98 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import responses | ||
import unittest | ||
from tests.test_sw360obj_base import Sw360ObjTestBase, SW360_BASE_URL | ||
from sw360 import Release | ||
|
||
|
||
class Sw360ObjTestRelease(Sw360ObjTestBase): | ||
def test_repr(self): | ||
r = Release(release_id="123", name="TestCmp", version="1.4", | ||
component_id="456", downloadurl="http://www") | ||
|
||
r = eval(repr(r)) | ||
assert r.id == "123" | ||
assert r.name == "TestCmp" | ||
assert r.version == "1.4" | ||
self.assertEqual(str(r), "TestCmp 1.4 (123)") | ||
|
||
r = Release() | ||
r = eval(repr(r)) | ||
assert r.id is None | ||
assert r.name is None | ||
assert r.version is None | ||
|
||
@responses.activate | ||
def test_get_release(self): | ||
responses.add( | ||
responses.GET, | ||
SW360_BASE_URL + "releases/123", | ||
json={ | ||
'name': 'acl', | ||
'version': '1.4', | ||
'somekey': 'value', | ||
'_links': { | ||
'sw360:component': { | ||
'href': SW360_BASE_URL + 'components/7b4'}}}) | ||
r = Release().get(self.lib, "123") | ||
self.assertEqual(r.name, "acl") | ||
self.assertEqual(r.details["somekey"], "value") | ||
self.assertEqual(len(r.purls), 0) | ||
self.assertEqual(r.component_id, "7b4") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |