def test_import_ref(self): self.mock(gitiles_import, '_import_config_set', mock.Mock()) self.mock(projects, 'get_project', mock.Mock()) self.mock(projects, 'get_refs', 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/heads/infra/config', ), ) projects.get_refs.return_value = { 'chromium': [ project_config_pb2.RefsCfg.Ref(name='refs/heads/release42', config_path='/my-configs'), ], } gitiles_import.import_ref('chromium', 'refs/heads/release42') gitiles_import._import_config_set.assert_called_once_with( 'projects/chromium/refs/heads/release42', gitiles.Location( hostname='localhost', project='chromium/src', treeish='refs/heads/release42', path='/my-configs', ), )
def test_import_ref_not_found(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(projects, 'get_ref', mock.Mock(return_value=None)) with self.assertRaises(gitiles_import.NotFoundError): gitiles_import.import_ref('chromium', 'refs/heads/release42')
def test_import_ref_not_found(self): 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/heads/infra/config', ), ) self.mock(projects, 'get_refs', mock.Mock(return_value={ 'chromium': [], })) with self.assertRaises(gitiles_import.NotFoundError): gitiles_import.import_ref('chromium', 'refs/heads/release42')
def test_import_ref(self): self.mock(gitiles_import, '_import_config_set', mock.Mock()) self.mock(projects, 'get_project', mock.Mock()) self.mock(projects, 'get_ref', 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, ), ) projects.get_ref.return_value = project_config_pb2.RefsCfg.Ref( name='refs/heads/release42', config_path='/my-configs', ) gitiles_import.import_ref('chromium', 'refs/heads/release42') gitiles_import._import_config_set.assert_called_once_with( 'projects/chromium/refs/heads/release42', 'https://localhost/chromium/src/+/refs/heads/release42/my-configs')
def test_import_ref_project_not_found(self): self.mock(projects, 'get_project', mock.Mock(return_value=None)) with self.assertRaises(gitiles_import.NotFoundError): gitiles_import.import_ref('chromium', 'refs/heads/release42')
def test_import_ref_project_not_found(self): self.mock(projects, 'get_project', mock.Mock(return_value=None)) with self.assertRaises(gitiles_import.NotFoundError): gitiles_import.import_ref('chromium', 'refs/heads/release42')