def test_import_project(self): self.mock(gitiles_import, '_import_config_set', mock.Mock()) self.mock(projects, 'get_project', mock.Mock()) projects.get_project.return_value = service_config_pb2.Project( id='chromium', config_location=service_config_pb2.ConfigSetLocation( url='https://localhost/chromium/src/', storage_type=service_config_pb2.ConfigSetLocation.GITILES, ), ) gitiles_import.import_project('chromium') gitiles_import._import_config_set.assert_called_once_with( 'projects/chromium', 'https://localhost/chromium/src/+/refs/heads/luci')
def test_import_project_ref_not_resolved(self): self.mock(projects, 'get_project', mock.Mock()) projects.get_project.return_value = service_config_pb2.Project( id='chromium', config_location=service_config_pb2.ConfigSetLocation( url='https://localhost/chromium/src/', storage_type=service_config_pb2.ConfigSetLocation.GITILES, ), ) self.mock(gitiles.Location, 'parse_resolve', mock.Mock(side_effect=gitiles.TreeishResolutionError())) storage.ConfigSet(id='projects/chromium', location='https://example.com').put() gitiles_import.import_project('chromium') self.assertIsNone(storage.ConfigSet.get_by_id('projects/chromium'))
def test_import_project(self): self.mock(gitiles_import, '_import_config_set', mock.Mock()) self.mock(projects, 'get_project', mock.Mock()) projects.get_project.return_value = service_config_pb2.Project( id='chromium', gitiles_location=service_config_pb2.GitilesLocation( repo='https://localhost/chromium/src', ref='refs/any/thing', path='infra/config/generated', ), ) gitiles_import.import_project('chromium') gitiles_import._import_config_set.assert_called_once_with( 'projects/chromium', gitiles.Location( hostname='localhost', project='chromium/src', treeish='refs/any/thing', path='/infra/config/generated', ), 'chromium')
def test_import_project_invalid_id(self): with self.assertRaises(ValueError): gitiles_import.import_project(')))')
def test_import_project_not_found(self): self.mock(projects, 'get_project', mock.Mock(return_value=None)) with self.assertRaises(gitiles_import.NotFoundError): gitiles_import.import_project('chromium')