def test_defect_service_defects(self, suds_client_mock, suds_security_mock, suds_username_mock): ''' Test login function of CoverityDefectService ''' suds_client_mock.return_value = MagicMock(spec=Client) suds_client_mock.return_value.service = MagicMock(spec=covservices.Service) suds_client_mock.return_value.service.getVersion = MagicMock() with open('tests/defect_soap.xml', 'rb') as xmlfile: defect_soap = objectify.fromstring(xmlfile.read()) suds_client_mock.return_value.service.getMergedDefectsForSnapshotScope = MagicMock(spec=defect_soap, return_value=defect_soap) suds_client_mock.return_value.factory = MagicMock() suds_security_mock.return_value = MagicMock(spec=Security) suds_security_mock.return_value.tokens = [] suds_username_mock.return_value = MagicMock(spec=UsernameToken, return_value="bljah") # Login to Coverity and obtain stream information coverity_conf_service = cov.CoverityConfigurationService('http', 'scan.coverity.com', '8080') suds_client_mock.assert_called_once_with('http://scan.coverity.com:8080/ws/v9/configurationservice?wsdl') # Test CoverityDefectService coverity_service = cov.CoverityDefectService(coverity_conf_service) suds_client_mock.assert_called_with('http://scan.coverity.com:8080/ws/v9/defectservice?wsdl') coverity_service.login('user', 'password') suds_security_mock.assert_called_once() suds_username_mock.assert_called_once_with('user', 'password') coverity_service.get_defects('projectname', 'somestream')
def test_defect_service_login(self, suds_client_mock, suds_security_mock, suds_username_mock): ''' Test login function of CoverityDefectService ''' suds_client_mock.return_value = MagicMock(spec=Client) suds_client_mock.return_value.service = MagicMock( spec=covservices.Service) suds_client_mock.return_value.service.getVersion = MagicMock() suds_security_mock.return_value = MagicMock(spec=Security) suds_security_mock.return_value.tokens = [] suds_username_mock.return_value = MagicMock(spec=UsernameToken, return_value="bljah") # Login to Coverity and obtain stream information coverity_conf_service = cov.CoverityConfigurationService( 'http', 'scan.coverity.com', '8080') suds_client_mock.assert_called_once_with( 'http://scan.coverity.com:8080/ws/v9/configurationservice?wsdl') # Test CoverityDefectService coverity_service = cov.CoverityDefectService(coverity_conf_service) suds_client_mock.assert_called_with( 'http://scan.coverity.com:8080/ws/v9/defectservice?wsdl') coverity_service.login('user', 'password') suds_security_mock.assert_called_once() suds_username_mock.assert_called_once_with('user', 'password')