Skip to content

Commit

Permalink
chore: updating requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-sheehan-edx committed Jul 27, 2023
1 parent 2bda6f1 commit 025dc0e
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 100 deletions.
25 changes: 16 additions & 9 deletions enterprise/management/commands/manufacture_factory_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
from django.db import connections

# We have to import the enterprise test factories to ensure it's loaded and found by __subclasses__
from test_utils import factories as _
from test_utils import factories # pylint: disable=unused-import

# To ensure factories outside of the enterprise package are loaded and found by the script,
# add any additionally desired factories as an import to this file. Make sure to catch the ImportError
# incase other consumers of the command do not have the same factories installed.
# For example:
try:
import common.djangoapps.student.test.factories as _
import common.djangoapps.student.test.factories # pylint: disable=unused-import
except ImportError:
pass

Expand Down Expand Up @@ -79,8 +79,15 @@ def run_from_argv(self, argv):
self._called_from_command_line = True
parser = self.create_parser(argv[0], argv[1])
options, unknown = parser.parse_known_args(argv[2:])
# pylint: disable=attribute-defined-outside-init
self.custom_attributes = unknown

# Add the unknowns into the options for use of the handle method
paired_unknowns = pairwise(unknown)
field_customizations = {}
for field, value in paired_unknowns:
field_customizations[field.strip("--")] = value
setattr(options, 'field_customizations', field_customizations)

# self.custom_attributes = unknown
cmd_options = vars(options)
# Move positional args out of options to mimic legacy optparse
args = cmd_options.pop("args", ())
Expand Down Expand Up @@ -123,18 +130,18 @@ def handle(self, *args, **options):
factory_model = potential_factory._meta.model
if f"{factory_model.__module__}.{factory_model.__name__}" == provided_model:
packed_factory_kwargs = {}
paired_attributes = pairwise(self.custom_attributes)
field_customizations = options.get('field_customizations')
# Confirm that the provided custom attributes are valid fields on the provided model
for field, value in paired_attributes:
striped_field = field.strip("--")
for field, value in field_customizations.items():
stripped_field = field.strip("--")
try:
factory_model._meta.get_field(striped_field)
factory_model._meta.get_field(stripped_field)
except FieldDoesNotExist as exc:
log.error(f"Provided field: {field} does not exist on {factory_model}")
raise CommandError(f'Provided field: {field} does not exist on {factory_model}') from exc
# Now that we know the custom attribute exists as a field on the provided model,
# add it to the kwargs dictionary for the record generation
packed_factory_kwargs[striped_field] = value
packed_factory_kwargs[stripped_field] = value

# Unpack the custom attributes into the kwargs of the factory, generate a record and return the pk
return str(potential_factory(**packed_factory_kwargs).pk)
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ tox==3.28.0
# tox-battery
tox-battery==0.6.1
# via -r requirements/ci.in
virtualenv==20.24.1
virtualenv==20.24.2
# via tox
2 changes: 2 additions & 0 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@




# A central location for most common version constraints
# (across edx repos) for pip-installation.
#
Expand Down
33 changes: 21 additions & 12 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ astroid==2.15.6
# pylint-celery
attrs==23.1.0
# via
# -r requirements/doc.txt
# -r requirements/test.txt
# pytest
babel==2.12.1
Expand Down Expand Up @@ -82,7 +83,7 @@ celery==5.3.1
# -r requirements/doc.txt
# -r requirements/test-master.txt
# -r requirements/test.txt
certifi==2023.5.7
certifi==2023.7.22
# via
# -r requirements/doc.txt
# -r requirements/test-master.txt
Expand Down Expand Up @@ -142,7 +143,7 @@ click-repl==0.3.0
# -r requirements/test-master.txt
# -r requirements/test.txt
# celery
code-annotations==1.3.0
code-annotations==1.5.0
# via
# -r requirements/doc.txt
# -r requirements/test-master.txt
Expand Down Expand Up @@ -172,7 +173,7 @@ defusedxml==0.7.1
# djangorestframework-xml
diff-cover==7.7.0
# via -r requirements/test.txt
dill==0.3.6
dill==0.3.7
# via pylint
distlib==0.3.7
# via virtualenv
Expand All @@ -188,6 +189,7 @@ django==3.2.20
# django-filter
# django-model-utils
# django-multi-email-field
# django-waffle
# djangorestframework
# drf-jwt
# edx-django-utils
Expand All @@ -200,7 +202,7 @@ django-cache-memoize==0.1.10
# -r requirements/doc.txt
# -r requirements/test-master.txt
# -r requirements/test.txt
django-config-models==2.3.0
django-config-models==2.4.0
# via
# -r requirements/doc.txt
# -r requirements/test-master.txt
Expand Down Expand Up @@ -254,7 +256,7 @@ django-simple-history==3.0.0
# -r requirements/doc.txt
# -r requirements/test-master.txt
# -r requirements/test.txt
django-waffle==3.0.0
django-waffle==4.0.0
# via
# -r requirements/doc.txt
# -r requirements/test-master.txt
Expand Down Expand Up @@ -290,7 +292,7 @@ drf-jwt==1.19.2
# -r requirements/test-master.txt
# -r requirements/test.txt
# edx-drf-extensions
edx-django-utils==5.5.0
edx-django-utils==5.6.0
# via
# -r requirements/doc.txt
# -r requirements/test-master.txt
Expand Down Expand Up @@ -332,9 +334,11 @@ edx-tincan-py35==1.0.0
factory-boy==3.3.0
# via
# -c requirements/constraints.txt
# -r requirements/doc.txt
# -r requirements/test.txt
faker==19.2.0
# via
# -r requirements/doc.txt
# -r requirements/test.txt
# factory-boy
filelock==3.12.2
Expand Down Expand Up @@ -366,6 +370,7 @@ importlib-metadata==6.8.0
# sphinx
iniconfig==2.0.0
# via
# -r requirements/doc.txt
# -r requirements/test.txt
# pytest
isort==5.12.0
Expand Down Expand Up @@ -471,6 +476,7 @@ platformdirs==3.9.1
# virtualenv
pluggy==1.2.0
# via
# -r requirements/doc.txt
# -r requirements/test.txt
# diff-cover
# pytest
Expand All @@ -491,6 +497,7 @@ psutil==5.9.5
# edx-django-utils
py==1.11.0
# via
# -r requirements/doc.txt
# -r requirements/test.txt
# pytest
# tox
Expand Down Expand Up @@ -530,7 +537,7 @@ pygments==2.15.1
# pydata-sphinx-theme
# readme-renderer
# sphinx
pyjwt[crypto]==2.7.0
pyjwt[crypto]==2.8.0
# via
# -r requirements/doc.txt
# -r requirements/test-master.txt
Expand All @@ -539,7 +546,7 @@ pyjwt[crypto]==2.7.0
# edx-drf-extensions
# edx-rest-api-client
# snowflake-connector-python
pylint==2.17.4
pylint==2.17.5
# via
# edx-lint
# pylint-celery
Expand Down Expand Up @@ -576,6 +583,7 @@ pyproject-hooks==1.0.0
pytest==6.2.5
# via
# -c requirements/constraints.txt
# -r requirements/doc.txt
# -r requirements/test.txt
# pytest-cov
# pytest-django
Expand Down Expand Up @@ -608,7 +616,7 @@ pytz==2022.7.1
# djangorestframework
# edx-tincan-py35
# snowflake-connector-python
pyyaml==6.0
pyyaml==6.0.1
# via
# -r requirements/doc.txt
# -r requirements/test-master.txt
Expand Down Expand Up @@ -752,6 +760,7 @@ text-unidecode==1.3
# python-slugify
toml==0.10.2
# via
# -r requirements/doc.txt
# -r requirements/test.txt
# pytest
tomli==2.0.1
Expand All @@ -765,7 +774,7 @@ tomli==2.0.1
# pylint
# pyproject-hooks
# tox
tomlkit==0.11.8
tomlkit==0.12.1
# via pylint
tox==3.28.0
# via
Expand Down Expand Up @@ -819,7 +828,7 @@ vine==5.0.0
# amqp
# celery
# kombu
virtualenv==20.24.1
virtualenv==20.24.2
# via tox
wcwidth==0.2.6
# via
Expand All @@ -833,7 +842,7 @@ webencodings==0.5.1
# -r requirements/test-master.txt
# -r requirements/test.txt
# bleach
wheel==0.40.0
wheel==0.41.0
# via
# -r requirements/dev.in
# pip-tools
Expand Down
2 changes: 2 additions & 0 deletions requirements/doc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ sphinx-book-theme # Common theme for all Open edX projects
readme_renderer # Validates README.rst for usage on PyPI
Sphinx # Documentation builder
docutils
factory-boy
pytest
Loading

0 comments on commit 025dc0e

Please sign in to comment.