Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initializedb creates Providers in database. (#849)
Issue #848
- Loading branch information
1 parent
f87d7ba
commit 700a721
Showing
3 changed files
with
103 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from sqlalchemy import select | ||
|
||
import tests | ||
from atramhasis.data.models import ExpandStrategy | ||
from atramhasis.data.models import IDGenerationStrategy | ||
from atramhasis.data.models import Provider | ||
from atramhasis.scripts import initializedb as script | ||
|
||
|
||
def setUpModule(): | ||
tests.setup_db(guarantee_empty=True) | ||
|
||
|
||
class TestMigrateTests(tests.DbTest): | ||
def test_initialize_providers(self): | ||
script.initialize_providers(self.session) | ||
|
||
expected_ids = [ | ||
'TREES', | ||
'GEOGRAPHY', | ||
'STYLE', | ||
'MATERIAL', | ||
'EVENTTYPE', | ||
'HERITAGETYPE', | ||
'PERIOD', | ||
'SPECIES', | ||
'BLUEBIRDS', | ||
] | ||
expected_concept_scheme_ids = [1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
for db_provider in self.session.execute(select(Provider)).scalars(): # type: Provider | ||
self.assertIn(db_provider.conceptscheme.id, expected_concept_scheme_ids) | ||
self.assertEqual(db_provider.id_generation_strategy, IDGenerationStrategy.NUMERIC) | ||
self.assertEqual(db_provider.expand_strategy, ExpandStrategy.RECURSE) | ||
self.assertIn(db_provider.id, expected_ids) |