Skip to content

Commit

Permalink
feat: Add manufacture_data django command
Browse files Browse the repository at this point in the history
style: fix whitespace issues

chore: fix import sorting

chore: remove unused import
  • Loading branch information
marlonkeating committed Feb 6, 2024
1 parent 0f0973d commit 5de9709
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Management command for making instances of models with test factories.
"""
from edx_django_utils.data_generation.management.commands.manufacture_data import Command as BaseCommand

from enterprise_access.apps.content_assignments.tests.factories import *
from enterprise_access.apps.core.tests.factories import *
from enterprise_access.apps.subsidy_access_policy.tests.factories import *
from enterprise_access.apps.subsidy_request.tests.factories import *


class Command(BaseCommand):
"""
Management command for generating Django records from factories with custom attributes
Example usage:
$ ./manage.py manufacture_data /
--model enterprise_access.apps.content_assignments.models.LearnerContentAssignment /
--learner_email "[email protected]"
"""
6 changes: 2 additions & 4 deletions enterprise_access/apps/core/tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Factoryboy factories.
"""
from uuid import uuid4

import factory
from faker import Faker

Expand All @@ -17,9 +15,9 @@ class UserFactory(factory.django.DjangoModelFactory):
"""
Test factory for the `User` model.
"""
id = factory.Sequence(lambda n: n + 1)
id = factory.Faker('bothify', text='#########')
# make this pretty random to avoid flaky tests.
username = factory.Sequence(lambda n: f'fake-username-{n}-{str(uuid4())[:8]}')
username = factory.Faker('bothify', text='fake-username-???###')
password = factory.PostGenerationMethodCall('set_password', USER_PASSWORD)
email = factory.Faker('email')
first_name = factory.Faker('first_name')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SubsidyAccessPolicyFactory(factory.django.DjangoModelFactory):
subsidy_uuid = factory.LazyFunction(uuid4)
access_method = AccessMethods.DIRECT
description = 'A generic description'
spend_limit = factory.LazyAttribute(lambda _: FAKER.pyint())
active = True


Expand Down
16 changes: 8 additions & 8 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ celery==5.3.6
# -r requirements/base.in
# django-celery-results
# edx-celeryutils
certifi==2023.11.17
certifi==2024.2.2
# via requests
cffi==1.16.0
# via
Expand Down Expand Up @@ -70,7 +70,7 @@ defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
django==4.2.9
django==4.2.10
# via
# -r requirements/base.in
# django-celery-results
Expand Down Expand Up @@ -147,7 +147,7 @@ edx-auth-backends==4.2.0
# via -r requirements/base.in
edx-braze-client==0.2.2
# via -r requirements/base.in
edx-celeryutils==1.2.3
edx-celeryutils==1.2.5
# via -r requirements/base.in
edx-django-release-util==1.3.0
# via -r requirements/base.in
Expand All @@ -156,7 +156,7 @@ edx-django-utils==5.10.1
# -r requirements/base.in
# edx-drf-extensions
# edx-rest-api-client
edx-drf-extensions==10.1.0
edx-drf-extensions==10.2.0
# via
# -r requirements/base.in
# edx-rbac
Expand Down Expand Up @@ -200,11 +200,11 @@ jsonschema-specifications==2023.12.1
# via jsonschema
kombu==5.3.5
# via celery
markupsafe==2.1.4
markupsafe==2.1.5
# via jinja2
monotonic==1.6
# via analytics-python
mysqlclient==2.2.1
mysqlclient==2.2.3
# via -r requirements/base.in
newrelic==9.6.0
# via edx-django-utils
Expand All @@ -214,7 +214,7 @@ oauthlib==3.2.2
# social-auth-core
openapi-codec==1.3.2
# via django-rest-swagger
openedx-events==9.3.0
openedx-events==9.4.0
# via -r requirements/base.in
packaging==23.2
# via drf-yasg
Expand Down Expand Up @@ -250,7 +250,7 @@ python-dateutil==2.8.2
# celery
python3-openid==3.2.0
# via social-auth-core
pytz==2023.4
pytz==2024.1
# via
# -r requirements/base.in
# djangorestframework
Expand Down
24 changes: 12 additions & 12 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ asgiref==3.7.2
# -r requirements/validation.txt
# django
# django-cors-headers
astroid==3.0.2
astroid==3.0.3
# via
# -r requirements/validation.txt
# pylint
Expand Down Expand Up @@ -58,7 +58,7 @@ celery==5.3.6
# -r requirements/validation.txt
# django-celery-results
# edx-celeryutils
certifi==2023.11.17
certifi==2024.2.2
# via
# -r requirements/validation.txt
# requests
Expand Down Expand Up @@ -152,7 +152,7 @@ distlib==0.3.8
# via
# -r requirements/validation.txt
# virtualenv
django==4.2.9
django==4.2.10
# via
# -r requirements/validation.txt
# django-celery-results
Expand Down Expand Up @@ -189,7 +189,7 @@ django-crum==0.7.9
# -r requirements/validation.txt
# edx-django-utils
# edx-rbac
django-debug-toolbar==4.2.0
django-debug-toolbar==4.3.0
# via -r requirements/dev.in
django-dynamic-fixture==4.0.1
# via -r requirements/validation.txt
Expand Down Expand Up @@ -244,7 +244,7 @@ edx-auth-backends==4.2.0
# via -r requirements/validation.txt
edx-braze-client==0.2.2
# via -r requirements/validation.txt
edx-celeryutils==1.2.3
edx-celeryutils==1.2.5
# via -r requirements/validation.txt
edx-django-release-util==1.3.0
# via -r requirements/validation.txt
Expand All @@ -253,7 +253,7 @@ edx-django-utils==5.10.1
# -r requirements/validation.txt
# edx-drf-extensions
# edx-rest-api-client
edx-drf-extensions==10.1.0
edx-drf-extensions==10.2.0
# via
# -r requirements/validation.txt
# edx-rbac
Expand Down Expand Up @@ -281,7 +281,7 @@ exceptiongroup==1.2.0
# pytest
factory-boy==3.3.0
# via -r requirements/validation.txt
faker==22.6.0
faker==22.7.0
# via
# -r requirements/validation.txt
# factory-boy
Expand Down Expand Up @@ -371,7 +371,7 @@ markdown-it-py==3.0.0
# via
# -r requirements/validation.txt
# rich
markupsafe==2.1.4
markupsafe==2.1.5
# via
# -r requirements/validation.txt
# jinja2
Expand All @@ -391,7 +391,7 @@ more-itertools==10.2.0
# via
# -r requirements/validation.txt
# jaraco-classes
mysqlclient==2.2.1
mysqlclient==2.2.3
# via -r requirements/validation.txt
newrelic==9.6.0
# via
Expand All @@ -410,7 +410,7 @@ openapi-codec==1.3.2
# via
# -r requirements/validation.txt
# django-rest-swagger
openedx-events==9.3.0
openedx-events==9.4.0
# via -r requirements/validation.txt
packaging==23.2
# via
Expand All @@ -421,7 +421,7 @@ packaging==23.2
# pyproject-api
# pytest
# tox
path==16.9.0
path==16.10.0
# via edx-i18n-tools
pbr==6.0.0
# via
Expand Down Expand Up @@ -547,7 +547,7 @@ python3-openid==3.2.0
# via
# -r requirements/validation.txt
# social-auth-core
pytz==2023.4
pytz==2024.1
# via
# -r requirements/validation.txt
# djangorestframework
Expand Down
2 changes: 1 addition & 1 deletion requirements/django.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
django==4.2.9
django==4.2.10
20 changes: 10 additions & 10 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ asgiref==3.7.2
# -r requirements/test.txt
# django
# django-cors-headers
astroid==3.0.2
astroid==3.0.3
# via
# -r requirements/test.txt
# pylint
Expand Down Expand Up @@ -64,7 +64,7 @@ celery==5.3.6
# -r requirements/test.txt
# django-celery-results
# edx-celeryutils
certifi==2023.11.17
certifi==2024.2.2
# via
# -r requirements/test.txt
# requests
Expand Down Expand Up @@ -152,7 +152,7 @@ distlib==0.3.8
# via
# -r requirements/test.txt
# virtualenv
django==4.2.9
django==4.2.10
# via
# -r requirements/test.txt
# django-celery-results
Expand Down Expand Up @@ -245,7 +245,7 @@ edx-auth-backends==4.2.0
# via -r requirements/test.txt
edx-braze-client==0.2.2
# via -r requirements/test.txt
edx-celeryutils==1.2.3
edx-celeryutils==1.2.5
# via -r requirements/test.txt
edx-django-release-util==1.3.0
# via -r requirements/test.txt
Expand All @@ -254,7 +254,7 @@ edx-django-utils==5.10.1
# -r requirements/test.txt
# edx-drf-extensions
# edx-rest-api-client
edx-drf-extensions==10.1.0
edx-drf-extensions==10.2.0
# via
# -r requirements/test.txt
# edx-rbac
Expand All @@ -280,7 +280,7 @@ exceptiongroup==1.2.0
# pytest
factory-boy==3.3.0
# via -r requirements/test.txt
faker==22.6.0
faker==22.7.0
# via
# -r requirements/test.txt
# factory-boy
Expand Down Expand Up @@ -347,7 +347,7 @@ kombu==5.3.5
# via
# -r requirements/test.txt
# celery
markupsafe==2.1.4
markupsafe==2.1.5
# via
# -r requirements/test.txt
# jinja2
Expand All @@ -359,7 +359,7 @@ monotonic==1.6
# via
# -r requirements/test.txt
# analytics-python
mysqlclient==2.2.1
mysqlclient==2.2.3
# via -r requirements/test.txt
newrelic==9.6.0
# via
Expand All @@ -376,7 +376,7 @@ openapi-codec==1.3.2
# via
# -r requirements/test.txt
# django-rest-swagger
openedx-events==9.3.0
openedx-events==9.4.0
# via -r requirements/test.txt
packaging==23.2
# via
Expand Down Expand Up @@ -497,7 +497,7 @@ python3-openid==3.2.0
# via
# -r requirements/test.txt
# social-auth-core
pytz==2023.4
pytz==2024.1
# via
# -r requirements/test.txt
# babel
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ wheel==0.42.0
# via -r requirements/pip.in

# The following packages are considered to be unsafe in a requirements file:
pip==23.3.2
pip==24.0
# via -r requirements/pip.in
setuptools==69.0.3
# via -r requirements/pip.in
16 changes: 8 additions & 8 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ celery==5.3.6
# -r requirements/base.txt
# django-celery-results
# edx-celeryutils
certifi==2023.11.17
certifi==2024.2.2
# via
# -r requirements/base.txt
# requests
Expand Down Expand Up @@ -99,7 +99,7 @@ defusedxml==0.8.0rc2
# -r requirements/base.txt
# python3-openid
# social-auth-core
django==4.2.9
django==4.2.10
# via
# -r requirements/base.txt
# django-celery-results
Expand Down Expand Up @@ -181,7 +181,7 @@ edx-auth-backends==4.2.0
# via -r requirements/base.txt
edx-braze-client==0.2.2
# via -r requirements/base.txt
edx-celeryutils==1.2.3
edx-celeryutils==1.2.5
# via -r requirements/base.txt
edx-django-release-util==1.3.0
# via -r requirements/base.txt
Expand All @@ -190,7 +190,7 @@ edx-django-utils==5.10.1
# -r requirements/base.txt
# edx-drf-extensions
# edx-rest-api-client
edx-drf-extensions==10.1.0
edx-drf-extensions==10.2.0
# via
# -r requirements/base.txt
# edx-rbac
Expand Down Expand Up @@ -258,15 +258,15 @@ kombu==5.3.5
# via
# -r requirements/base.txt
# celery
markupsafe==2.1.4
markupsafe==2.1.5
# via
# -r requirements/base.txt
# jinja2
monotonic==1.6
# via
# -r requirements/base.txt
# analytics-python
mysqlclient==2.2.1
mysqlclient==2.2.3
# via
# -r requirements/base.txt
# -r requirements/production.in
Expand All @@ -283,7 +283,7 @@ openapi-codec==1.3.2
# via
# -r requirements/base.txt
# django-rest-swagger
openedx-events==9.3.0
openedx-events==9.4.0
# via -r requirements/base.txt
packaging==23.2
# via
Expand Down Expand Up @@ -344,7 +344,7 @@ python3-openid==3.2.0
# via
# -r requirements/base.txt
# social-auth-core
pytz==2023.4
pytz==2024.1
# via
# -r requirements/base.txt
# djangorestframework
Expand Down
Loading

0 comments on commit 5de9709

Please sign in to comment.