Skip to content

Commit

Permalink
Update all backend dependencies. Modify factories to be compatible wi…
Browse files Browse the repository at this point in the history
…th the newest version of Faker.
  • Loading branch information
Svetlitski committed Jan 22, 2021
1 parent fb6175c commit 1f49652
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
25 changes: 15 additions & 10 deletions csm_web/scheduler/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
week_bounds
)


def evaluate_faker(faker):
return faker.evaluate(None, None, {'locale': None})


COMPSCI_WORDS = ('Algorithms', 'Systems', 'Distributed', 'Efficient', 'Tractable', 'Programming',
'Languages', 'Machine Learning', 'AI', 'Blockchain', 'Parallel', 'Architecture')

Expand All @@ -33,29 +38,29 @@ class Meta:
valid_until = factory.Faker("date_between", start_date="+5w", end_date="+18w")
enrollment_start = factory.LazyAttribute(
lambda o: timezone.make_aware(
factory.Faker(
evaluate_faker(factory.Faker(
"date_time_between_dates",
datetime_start=timezone.now() - timedelta(weeks=3),
datetime_end=timezone.now() - timedelta(weeks=2),
).generate({})
))
)
)
section_start = factory.LazyAttribute(
lambda o: timezone.make_aware(
factory.Faker(
evaluate_faker(factory.Faker(
"date_time_between_dates",
datetime_start=o.enrollment_start + timedelta(weeks=1),
datetime_end=o.enrollment_start + timedelta(weeks=3),
).generate({})
))
)
)
enrollment_end = factory.LazyAttribute(
lambda o: timezone.make_aware(
factory.Faker(
evaluate_faker(factory.Faker(
"date_time_between_dates",
datetime_start=timezone.now() + timedelta(weeks=2),
datetime_end=o.valid_until,
).generate({})
))
)
)
permitted_absences = factory.LazyFunction(lambda: random.randint(1, 4))
Expand Down Expand Up @@ -83,8 +88,8 @@ class UserFactory(factory.django.DjangoModelFactory):
class Meta:
model = User

first_name = factory.LazyFunction(lambda: factory.Faker("name").generate({}).split()[0])
last_name = factory.LazyFunction(lambda: factory.Faker("name").generate({}).split()[-1])
first_name = factory.LazyFunction(lambda: evaluate_faker(factory.Faker("name")).split()[0])
last_name = factory.LazyFunction(lambda: evaluate_faker(factory.Faker("name")).split()[-1])
username = factory.LazyAttributeSequence(lambda o, n: "%s_%s%d" % (o.first_name, o.last_name, n))
email = factory.LazyAttribute(lambda o: "%[email protected]" % o.username)

Expand Down Expand Up @@ -140,11 +145,11 @@ class Meta:

@factory.lazy_attribute
def date(obj):
date = factory.Faker(
date = evaluate_faker(factory.Faker(
"date_between_dates",
date_start=obj.overriden_spacetime.section.course.enrollment_start.date(),
date_end=obj.overriden_spacetime.section.course.valid_until,
).generate({})
))
return date + timedelta(days=(day_to_number(obj.spacetime.day_of_week) - date.weekday()))

spacetime = factory.SubFactory(SpacetimeFactory)
Expand Down
48 changes: 24 additions & 24 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
asgiref==3.2.10
asgiref==3.3.1
Brotli==1.0.9
certifi==2019.6.16
cffi==1.14.2
chardet==3.0.4
cryptography==3.2.1
certifi==2020.12.5
cffi==1.14.4
chardet==4.0.0
cryptography==3.3.1
defusedxml==0.6.0
dj-database-url==0.5.0
Django==3.1.1
Django==3.1.5
django-csp==3.7
django-extensions==3.0.8
django-extensions==3.1.0
django-heroku==0.3.1
djangorestframework==3.11.1
djangorestframework==3.12.2
djangorestframework-camel-case==1.2.0
factory-boy==3.0.1
Faker==2.0.1
factory-boy==3.2.0
Faker==5.6.5
gunicorn==20.0.4
idna==2.8
idna==2.10
oauthlib==3.1.0
psycopg2-binary==2.8.6
pycparser==2.20
PyJWT==1.7.1
python-dateutil==2.8.0
PyJWT==2.0.1
python-dateutil==2.8.1
python-social-auth==0.3.6
python3-openid==3.1.0
pytz==2019.2
PyYAML==5.1.2
requests==2.22.0
requests-oauthlib==1.2.0
sentry-sdk==0.17.4
six==1.12.0
python3-openid==3.2.0
pytz==2020.5
PyYAML==5.4.1
requests==2.25.1
requests-oauthlib==1.3.0
sentry-sdk==0.19.5
six==1.15.0
social-auth-app-django==4.0.0
social-auth-core==3.3.3
sqlparse==0.3.0
text-unidecode==1.2
urllib3==1.25.3
social-auth-core==4.0.3
sqlparse==0.4.1
text-unidecode==1.3
urllib3==1.26.2
whitenoise==5.2.0

0 comments on commit 1f49652

Please sign in to comment.