@@ -839,11 +839,73 @@ def xtest_get_component_real(self) -> None:
839839 lib .login_api ()
840840 # c = lib.get_component("eaba2f0416e000e8ca5b2ccb4400633e")
841841 # c = lib.get_components_by_external_id( "package-url", "pkg:nuget/Tethys.Logging")
842- c = lib .api_get ("https://sw360.siemens .com/resource/api/components/searchByExternalIds?package-url=pkg:nuget/Tethys.Logging" ) # noqa
842+ c = lib .api_get ("https://my.server .com/resource/api/components/searchByExternalIds?package-url=pkg:nuget/Tethys.Logging" ) # noqa
843843 print (c )
844844
845+ @responses .activate
846+ def test_get_recent_components (self ) -> None :
847+ lib = SW360 (self .MYURL , self .MYTOKEN , False )
848+ lib .force_no_session = True
849+ self ._add_login_response ()
850+ actual = lib .login_api ()
851+ self .assertTrue (actual )
852+
853+ responses .add (
854+ method = responses .GET ,
855+ url = self .MYURL + "resource/api/components/recentComponents" ,
856+ body = '''{
857+ "_embedded": {
858+ "sw360:components": [
859+ {
860+ "id": "ff6f1b5b212b4f93b306e2cceca4f64d",
861+ "name": "intl-listformat",
862+ "description": "n/a",
863+ "componentType": "OSS",
864+ "visbility": "EVERYONE",
865+ "mainLicenseIds": [],
866+ "_links": {
867+ "self": {
868+ "href": "https://my.server.com/resource/api/components/ff"
869+ }
870+ }
871+ },
872+ {
873+ "id": "f916b35d6c864014bd8823c45615aeab",
874+ "name": "fields-metadata-plugin",
875+ "description": "n/a",
876+ "componentType": "OSS",
877+ "visbility": "EVERYONE",
878+ "mainLicenseIds": [],
879+ "_links": {
880+ "self": {
881+ "href": "https://my.server.com/resource/api/components/f9"
882+ }
883+ }
884+ }
885+ ]
886+ },
887+ "_links": {
888+ "curies": [
889+ {
890+ "href": "https://my.server.com/resource/docs/{rel}.html",
891+ "name": "sw360",
892+ "templated": true
893+ }
894+ ]
895+ }
896+ }''' ,
897+ status = 200 ,
898+ content_type = "application/json" ,
899+ adding_headers = {"Authorization" : "Token " + self .MYTOKEN },
900+ )
901+
902+ components = lib .get_recent_components ()
903+ self .assertIsNotNone (components )
904+ self .assertEqual (2 , len (components ))
905+ self .assertEqual ("intl-listformat" , components [0 ]["name" ])
906+ self .assertEqual ("OSS" , components [0 ]["componentType" ])
907+
845908
846909if __name__ == "__main__" :
847- # unittest.main()
848910 x = Sw360TestComponents ()
849911 x .test_get_all_components_with_fields_and_paging ()
0 commit comments