Skip to content

Commit df188ff

Browse files
committed
Updated test factories
1 parent 17e6456 commit df188ff

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

sde_collections/tests/factories.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,20 @@ class Meta:
6161
url = factory.Faker("url")
6262
scraped_title = factory.Faker("sentence")
6363
scraped_text = factory.Faker("paragraph")
64+
division = Divisions.ASTROPHYSICS
6465
# generated_title = factory.Faker("sentence")
6566
# visited = factory.Faker("boolean")
6667
# document_type = 1
6768
# division = 1
6869

70+
@factory.post_generation
71+
def set_default_tdamm_tag(self, create, extracted, **kwargs):
72+
if not create:
73+
return
74+
# Initialize tdamm_tag fields to empty lists by default
75+
self.tdamm_tag_manual = []
76+
self.tdamm_tag_ml = []
77+
6978

7079
class DeltaUrlFactory(factory.django.DjangoModelFactory):
7180
class Meta:
@@ -75,6 +84,15 @@ class Meta:
7584
url = factory.Faker("url")
7685
scraped_title = factory.Faker("sentence")
7786
to_delete = False
87+
division = Divisions.ASTROPHYSICS
88+
89+
@factory.post_generation
90+
def set_default_tdamm_tag(self, create, extracted, **kwargs):
91+
if not create:
92+
return
93+
# Initialize tdamm_tag fields to empty lists by default
94+
self.tdamm_tag_manual = []
95+
self.tdamm_tag_ml = []
7896

7997

8098
class CuratedUrlFactory(factory.django.DjangoModelFactory):
@@ -88,4 +106,12 @@ class Meta:
88106
generated_title = factory.Faker("sentence")
89107
visited = factory.Faker("boolean")
90108
document_type = 1
91-
division = 1
109+
division = Divisions.ASTROPHYSICS
110+
111+
@factory.post_generation
112+
def set_default_tdamm_tag(self, create, extracted, **kwargs):
113+
if not create:
114+
return
115+
# Initialize tdamm_tag fields to empty lists by default
116+
self.tdamm_tag_manual = []
117+
self.tdamm_tag_ml = []

0 commit comments

Comments
 (0)