def test_get_resource_table_not_available(self): taxonomy_repo = TaxonomyRepo() with patch( 'microsetta_public_api.repo._taxonomy_repo.TaxonomyRepo' '.tables', new_callable=PropertyMock) as mock_tables: mock_tables.return_value = { 'foo': { 'table': 'some-tb' }, 'bar': { 'table': 'some-other-tb' } } with self.assertRaisesRegex( ValueError, 'No table with taxonomy ' 'available for ' '`bad-table`'): taxonomy_repo._get_resource('bad-table')
def test_get_resource_component(self): taxonomy_repo = TaxonomyRepo() with patch( 'microsetta_public_api.repo._taxonomy_repo.TaxonomyRepo' '.tables', new_callable=PropertyMock) as mock_tables: mock_tables.return_value = { 'foo': { 'table': 'some-tb', 'variances': 'var-tb' }, 'bar': { 'table': 'some-other-tb' } } res = taxonomy_repo._get_resource('bar') self.assertDictEqual({'table': 'some-other-tb'}, res)