diff --git a/test/factories.py b/test/factories.py index 8fff396..65d59f2 100644 --- a/test/factories.py +++ b/test/factories.py @@ -7,8 +7,8 @@ from faker import Faker from odp.db import Session -from odp.db.models import (Catalog, Client, Collection, CollectionTag, Provider, Record, RecordTag, Role, Schema, Scope, Tag, User, - Vocabulary, VocabularyTerm) +from odp.db.models import (Archive, Catalog, Client, Collection, CollectionTag, Provider, Record, + RecordTag, Role, Schema, Scope, Tag, User, Vocabulary, VocabularyTerm) from test import datacite4_example, iso19115_example fake = Faker() @@ -329,3 +329,11 @@ def collections(obj, create, collections): obj.collections.append(collection) if create: Session.commit() + + +class ArchiveFactory(ODPModelFactory): + class Meta: + model = Archive + + id = factory.Sequence(lambda n: f'{fake.slug()}.{n}') + url = factory.Faker('url') diff --git a/test/test_db.py b/test/test_db.py index 421e858..4fa2c8d 100644 --- a/test/test_db.py +++ b/test/test_db.py @@ -5,9 +5,9 @@ import migrate.systemdata from odp.const import ODPScope, ODPSystemRole from odp.db import Session -from odp.db.models import (Catalog, Client, ClientCollection, ClientScope, Collection, CollectionTag, Provider, Record, RecordTag, Role, +from odp.db.models import (Archive, Catalog, Client, ClientCollection, ClientScope, Collection, CollectionTag, Provider, Record, RecordTag, Role, RoleCollection, RoleScope, Schema, Scope, ScopeType, Tag, User, UserRole, Vocabulary, VocabularyTerm) -from test.factories import (CatalogFactory, ClientFactory, CollectionFactory, CollectionTagFactory, ProviderFactory, RecordFactory, +from test.factories import (ArchiveFactory, CatalogFactory, ClientFactory, CollectionFactory, CollectionTagFactory, ProviderFactory, RecordFactory, RecordTagFactory, RoleFactory, SchemaFactory, ScopeFactory, TagFactory, UserFactory, VocabularyFactory) @@ -43,6 +43,12 @@ def test_db_setup(): ) +def test_create_archive(): + archive = ArchiveFactory() + result = Session.execute(select(Archive)).scalar_one() + assert (result.id, result.url) == (archive.id, archive.url) + + def test_create_catalog(): catalog = CatalogFactory() result = Session.execute(select(Catalog)).scalar_one()