From 5de9709ffd6098a4a77a7ffd21ac98cd31e5b20a Mon Sep 17 00:00:00 2001 From: Marlon Keating Date: Tue, 6 Feb 2024 21:00:56 +0000 Subject: [PATCH] feat: Add manufacture_data django command style: fix whitespace issues chore: fix import sorting chore: remove unused import --- .../management/commands/manufacture_data.py | 20 ++++++++++++++++ .../apps/core/tests/factories.py | 6 ++--- .../subsidy_access_policy/tests/factories.py | 1 + requirements/base.txt | 16 ++++++------- requirements/dev.txt | 24 +++++++++---------- requirements/django.txt | 2 +- requirements/doc.txt | 20 ++++++++-------- requirements/pip.txt | 2 +- requirements/production.txt | 16 ++++++------- requirements/quality.txt | 20 ++++++++-------- requirements/test.txt | 18 +++++++------- requirements/validation.txt | 20 ++++++++-------- 12 files changed, 92 insertions(+), 73 deletions(-) create mode 100644 enterprise_access/apps/core/management/commands/manufacture_data.py diff --git a/enterprise_access/apps/core/management/commands/manufacture_data.py b/enterprise_access/apps/core/management/commands/manufacture_data.py new file mode 100644 index 00000000..79b82b8d --- /dev/null +++ b/enterprise_access/apps/core/management/commands/manufacture_data.py @@ -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 "test@email.com" + """ diff --git a/enterprise_access/apps/core/tests/factories.py b/enterprise_access/apps/core/tests/factories.py index c748814a..ec520e94 100644 --- a/enterprise_access/apps/core/tests/factories.py +++ b/enterprise_access/apps/core/tests/factories.py @@ -1,8 +1,6 @@ """ Factoryboy factories. """ -from uuid import uuid4 - import factory from faker import Faker @@ -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') diff --git a/enterprise_access/apps/subsidy_access_policy/tests/factories.py b/enterprise_access/apps/subsidy_access_policy/tests/factories.py index fccf6ec2..e91fd4ca 100644 --- a/enterprise_access/apps/subsidy_access_policy/tests/factories.py +++ b/enterprise_access/apps/subsidy_access_policy/tests/factories.py @@ -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 diff --git a/requirements/base.txt b/requirements/base.txt index 31f3d8f9..47415e45 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/requirements/dev.txt b/requirements/dev.txt index 07737bfa..e3e7fdcb 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/requirements/django.txt b/requirements/django.txt index 01c70d8d..1facfe28 100644 --- a/requirements/django.txt +++ b/requirements/django.txt @@ -1 +1 @@ -django==4.2.9 +django==4.2.10 diff --git a/requirements/doc.txt b/requirements/doc.txt index a4249a11..9799a57a 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/requirements/pip.txt b/requirements/pip.txt index a4cf5307..dfa2b778 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -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 diff --git a/requirements/production.txt b/requirements/production.txt index 9f210471..e1eee97a 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -258,7 +258,7 @@ kombu==5.3.5 # via # -r requirements/base.txt # celery -markupsafe==2.1.4 +markupsafe==2.1.5 # via # -r requirements/base.txt # jinja2 @@ -266,7 +266,7 @@ 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 @@ -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 @@ -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 diff --git a/requirements/quality.txt b/requirements/quality.txt index 2a89534b..9a34c16b 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -15,7 +15,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 @@ -54,7 +54,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 @@ -143,7 +143,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 @@ -229,7 +229,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 @@ -238,7 +238,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 @@ -266,7 +266,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 @@ -344,7 +344,7 @@ kombu==5.3.5 # celery markdown-it-py==3.0.0 # via rich -markupsafe==2.1.4 +markupsafe==2.1.5 # via # -r requirements/test.txt # jinja2 @@ -360,7 +360,7 @@ monotonic==1.6 # analytics-python more-itertools==10.2.0 # via jaraco-classes -mysqlclient==2.2.1 +mysqlclient==2.2.3 # via -r requirements/test.txt newrelic==9.6.0 # via @@ -377,7 +377,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 @@ -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 # djangorestframework diff --git a/requirements/test.txt b/requirements/test.txt index c9ad4e6c..8832ee34 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -15,7 +15,7 @@ asgiref==3.7.2 # -r requirements/base.txt # django # django-cors-headers -astroid==3.0.2 +astroid==3.0.3 # via # pylint # pylint-celery @@ -51,7 +51,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 @@ -211,7 +211,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 @@ -220,7 +220,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 @@ -244,7 +244,7 @@ exceptiongroup==1.2.0 # via pytest factory-boy==3.3.0 # via -r requirements/test.in -faker==22.6.0 +faker==22.7.0 # via factory-boy fastavro==1.9.3 # via @@ -299,7 +299,7 @@ kombu==5.3.5 # via # -r requirements/base.txt # celery -markupsafe==2.1.4 +markupsafe==2.1.5 # via # -r requirements/base.txt # jinja2 @@ -309,7 +309,7 @@ monotonic==1.6 # via # -r requirements/base.txt # analytics-python -mysqlclient==2.2.1 +mysqlclient==2.2.3 # via -r requirements/base.txt newrelic==9.6.0 # via @@ -324,7 +324,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 @@ -421,7 +421,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 diff --git a/requirements/validation.txt b/requirements/validation.txt index 3686003a..c59af0d7 100644 --- a/requirements/validation.txt +++ b/requirements/validation.txt @@ -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/quality.txt # -r requirements/test.txt @@ -66,7 +66,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/quality.txt # -r requirements/test.txt @@ -177,7 +177,7 @@ distlib==0.3.8 # -r requirements/quality.txt # -r requirements/test.txt # virtualenv -django==4.2.9 +django==4.2.10 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -298,7 +298,7 @@ edx-braze-client==0.2.2 # via # -r requirements/quality.txt # -r requirements/test.txt -edx-celeryutils==1.2.3 +edx-celeryutils==1.2.5 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -312,7 +312,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/quality.txt # -r requirements/test.txt @@ -350,7 +350,7 @@ factory-boy==3.3.0 # via # -r requirements/quality.txt # -r requirements/test.txt -faker==22.6.0 +faker==22.7.0 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -451,7 +451,7 @@ markdown-it-py==3.0.0 # via # -r requirements/quality.txt # rich -markupsafe==2.1.4 +markupsafe==2.1.5 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -474,7 +474,7 @@ more-itertools==10.2.0 # via # -r requirements/quality.txt # jaraco-classes -mysqlclient==2.2.1 +mysqlclient==2.2.3 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -498,7 +498,7 @@ openapi-codec==1.3.2 # -r requirements/quality.txt # -r requirements/test.txt # django-rest-swagger -openedx-events==9.3.0 +openedx-events==9.4.0 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -650,7 +650,7 @@ python3-openid==3.2.0 # -r requirements/quality.txt # -r requirements/test.txt # social-auth-core -pytz==2023.4 +pytz==2024.1 # via # -r requirements/quality.txt # -r requirements/test.txt