fix: stop using factoryboy internals
@@ -167,7 +167,8 @@ class RawDatumFactory(DjangoModelFactory):
class HarvestJobFactory(DjangoModelFactory):
source_config = factory.SubFactory(SourceConfigFactory)
- start_date = factory.Faker('date_time')
+ start_date = factory.Faker('date_object')
+ end_date = factory.LazyAttribute(lambda job: job.start_date + datetime.timedelta(days=1))
source_config_version = factory.SelfAttribute('source_config.version')
harvester_version = factory.SelfAttribute('source_config.harvester.version')
@@ -175,14 +176,6 @@ class HarvestJobFactory(DjangoModelFactory):
class Meta:
model = models.HarvestJob
- @classmethod
- def _generate(cls, create, attrs):
- if isinstance(attrs['start_date'], datetime.datetime):
- attrs['start_date'] = attrs['start_date'].date()
- if not attrs.get('end_date'):
- attrs['end_date'] = attrs['start_date'] + datetime.timedelta(days=1)
- return super()._generate(create, attrs)
-
class IngestJobFactory(DjangoModelFactory):
source_config = factory.SelfAttribute('suid.source_config')
