Skip to content

Commit

Permalink
By default don't create parent for factory record
Browse files Browse the repository at this point in the history
  • Loading branch information
marksparkza committed Aug 11, 2023
1 parent 28c4d79 commit 97e69b8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/api/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def test_delete_collection(api, collection_batch, scopes, collection_auth, has_r
del modified_collection_batch[2]

if has_record:
RecordFactory(collection=collection_batch[2], is_child_record=False)
RecordFactory(collection=collection_batch[2])

r = api(scopes, api_client_collections).delete(f'/collection/{collection_batch[2].id}')

Expand Down
2 changes: 1 addition & 1 deletion test/api/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_delete_provider(api, provider_batch, scopes, has_record):

if has_record:
if collection := next((c for c in provider_batch[2].collections), None):
RecordFactory(collection=collection, is_child_record=False)
RecordFactory(collection=collection)
else:
has_record = False

Expand Down
4 changes: 2 additions & 2 deletions test/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ class Meta:
SchemaFactory(id=r.schema_id, type='metadata'))
timestamp = factory.LazyFunction(lambda: datetime.now(timezone.utc))

is_child_record = factory.LazyFunction(lambda: randint(0, 1))
is_child_record = False
parent = factory.Maybe(
'is_child_record',
yes_declaration=factory.SubFactory('test.factories.RecordFactory', is_child_record=False),
yes_declaration=factory.SubFactory('test.factories.RecordFactory'),
no_declaration=None,
)

Expand Down
4 changes: 3 additions & 1 deletion test/test_db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from random import randint

from sqlalchemy import select

import migrate.systemdata
Expand Down Expand Up @@ -90,7 +92,7 @@ def test_create_provider():


def test_create_record():
record = RecordFactory()
record = RecordFactory(is_child_record=randint(0, 1))
result = Session.execute(
select(Record).where(Record.id == record.id)
).scalar_one()
Expand Down

0 comments on commit 97e69b8

Please sign in to comment.