Skip to content

Commit

Permalink
BOM-1079 Django22 Support
Browse files Browse the repository at this point in the history
-updated tox and travis configs
-updated requirements
-updated setup file
-fixed tests
-updated trove classifiers
-include deprication warnings
-fixed quality
  • Loading branch information
Ayub-Khan committed Dec 6, 2019
1 parent ea15608 commit 2009365
Show file tree
Hide file tree
Showing 29 changed files with 240 additions and 205 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -27,7 +27,6 @@ instructions.
- [ ] Changelog record added
- [ ] Documentation updated (not only docstrings)
- [ ] Commits are squashed
- [ ] PR author is listed in AUTHORS

**Post merge:**
- [ ] Create a tag
Expand Down
19 changes: 15 additions & 4 deletions .travis.yml
Expand Up @@ -4,17 +4,27 @@ language: python

python:
- 2.7
- 3.6
- 3.5

env:
- TOXENV=django111
- TOXENV=django20
- TOXENV=django21
- TOXENV=django22

matrix:
include:
- python: 3.6
- python: 3.5
env: TOXENV=quality
- python: 3.6
- python: 3.5
env: TOXENV=docs
exclude:
- python: 2.7
env: TOXENV=django20
- python: 2.7
env: TOXENV=django21
- python: 2.7
env: TOXENV=django22

cache:
- pip
Expand All @@ -39,4 +49,5 @@ deploy:
distributions: sdist bdist_wheel
on:
tags: true
python: 3.6
condition: "$TOXENV = quality"
python: 3.5
3 changes: 0 additions & 3 deletions AUTHORS

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -16,6 +16,11 @@ Unreleased

*

0.1.13] - 2019-12-06
~~~~~~~~~~~~~~~~~~~~~

* Django22 Support.

0.1.12] - 2019-10-16
~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
@@ -1,6 +1,4 @@
include AUTHORS
include CHANGELOG.rst
include CONTRIBUTING.rst
include LICENSE.txt
include README.rst
include requirements/base.in
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Expand Up @@ -43,11 +43,11 @@ docs: ## generate Sphinx HTML documentation, including API docs
upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -q pip-tools
pip-compile --upgrade -o requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in
pip-compile --upgrade -o requirements/doc.txt requirements/base.in requirements/doc.in
pip-compile --upgrade -o requirements/quality.txt requirements/quality.in
pip-compile --upgrade -o requirements/test.txt requirements/base.in requirements/test.in
pip-compile --upgrade -o requirements/travis.txt requirements/travis.in
pip-compile --rebuild --upgrade -o requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in
pip-compile --rebuild --upgrade -o requirements/doc.txt requirements/base.in requirements/doc.in
pip-compile --rebuild --upgrade -o requirements/quality.txt requirements/quality.in
pip-compile --rebuild --upgrade -o requirements/test.txt requirements/base.in requirements/test.in
pip-compile --rebuild --upgrade -o requirements/travis.txt requirements/travis.in
# Let tox control the Django version for tests
sed '/^django==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt
Expand Down
2 changes: 1 addition & 1 deletion edx_ace/__init__.py
Expand Up @@ -15,7 +15,7 @@
from .recipient import Recipient
from .recipient_resolver import RecipientResolver

__version__ = u'0.1.12'
__version__ = u'0.1.13'

default_app_config = u'edx_ace.apps.EdxAceConfig'

Expand Down
3 changes: 2 additions & 1 deletion edx_ace/channel/file.py
Expand Up @@ -89,13 +89,14 @@ def deliver(self, message, rendered_message):
date=datetime.now()
))
make_parent_directories(output_file_path)
with open(output_file_path, u'w') as output_file: # pylint: disable=open-builtin
with open(output_file_path, u'w') as output_file:
output_file.write(self._encode(rendered_template))

print(self._encode(STDOUT_TEMPLATE.format(**template_vars)))


def make_parent_directories(path):
""" helper Method for creating parent directories. """
parent_dir_path = os.path.dirname(os.path.realpath(path))
try:
os.makedirs(parent_dir_path)
Expand Down
7 changes: 4 additions & 3 deletions edx_ace/channel/sailthru.py
Expand Up @@ -178,9 +178,10 @@ def __init__(self):
def deliver(self, message, rendered_message):
if message.recipient.email_address is None:
raise InvalidMessageError(
u'No email address specified for recipient %s while sending message %s',
message.recipient,
message.log_id
u'No email address specified for recipient {} while sending message {}'.format(
message.recipient,
message.log_id
)
)

template_vars, options = {}, {}
Expand Down
4 changes: 3 additions & 1 deletion edx_ace/message.py
Expand Up @@ -144,7 +144,7 @@ def process(self, msg, kwargs):
def debug(self, msg, *args, **kwargs):
log_level = self.extra[u'message'].log_level
if log_level and log_level <= logging.DEBUG:
return self.info(msg, *args, **kwargs)
self.info(msg, *args, **kwargs)
else:
super(MessageLoggingAdapter, self).debug(msg, *args, **kwargs)

Expand Down Expand Up @@ -198,13 +198,15 @@ def generate_uuid(self):

@name.default
def default_name(self):
""" Return default class name. """
if self.NAME is None:
return self.__class__.__name__.lower()
else:
return self.NAME

@app_label.default
def default_app_label(self):
u""" Get default app Label. """
if self.APP_LABEL is None:
return apps.get_containing_app_config(self.__class__.__module__).label
else:
Expand Down
1 change: 1 addition & 0 deletions edx_ace/serialization.py
Expand Up @@ -108,6 +108,7 @@ def _deserialize_field(cls, field_name, field_value):


class MessageEncoder(json.JSONEncoder):
""" Custom Message Encoder. """
# The Pylint error is disabled because of a bug in Pylint.
# See https://github.com/PyCQA/pylint/issues/414
def default(self, o): # pylint: disable=method-hidden
Expand Down
3 changes: 2 additions & 1 deletion edx_ace/test_utils/__init__.py
@@ -1,7 +1,7 @@
u"""
Test utilities.
Since py.test discourages putting __init__.py into test directory (i.e. making tests a package)
Since pytest discourages putting __init__.py into test directory (i.e. making tests a package)
one cannot import from anywhere under tests folder. However, some utility classes/methods might be useful
in multiple test modules (i.e. factoryboy factories, base test classes). So this package is the place to put them.
"""
Expand All @@ -13,6 +13,7 @@


class StubPolicy(policy.Policy):
""" Short term policy. """
def __init__(self, deny_value):
self.deny_value = frozenset(deny_value)

Expand Down
2 changes: 1 addition & 1 deletion edx_ace/tests/test_date.py
Expand Up @@ -14,7 +14,7 @@


class TestDateSerialization(TestCase):

""" Test Date Serialization. """
@given(st.one_of(st.datetimes(timezones=st.none() | timezones()), st.none()))
@example(datetime(16, 1, 1, 0, 0, 16))
def test_round_trip(self, date):
Expand Down
3 changes: 2 additions & 1 deletion edx_ace/tests/test_message.py
Expand Up @@ -71,7 +71,7 @@ def test_basic(self):
for key in self.msg_kwargs:
self.assertEqual(getattr(transactional_message, key), self.msg_kwargs.get(key))
self.assertIsNotNone(transactional_message.uuid)
assert transactional_message.options.get(u'transactional') # pylint: disable=no-member
assert transactional_message.options.get(u'transactional')

normal_message = Message(**self.msg_kwargs)
assert not dict(normal_message.options)
Expand Down Expand Up @@ -145,6 +145,7 @@ class CustomType(MessageType):


class TestMessageTypes(TestCase):
""" Test Message Types. """
@given(msg_type)
def test_serialization_roundtrip(self, message_type):
serialized = six.text_type(message_type)
Expand Down
1 change: 1 addition & 0 deletions edx_ace/tests/test_policy.py
Expand Up @@ -16,6 +16,7 @@

@ddt.ddt
class TestPolicy(TestCase):
""" Test Policies. """
PolicyCase = namedtuple(u'PolicyCase', u'deny_values, expected_channels')

@ddt.data(
Expand Down
30 changes: 19 additions & 11 deletions pylintrc
Expand Up @@ -26,17 +26,28 @@
# 1. Edit the pylintrc file in the edx-lint repo at
# https://github.com/edx/edx-lint/blob/master/edx_lint/files/pylintrc
#
# 2. Make a new version of edx_lint, which involves the usual steps of
# incrementing the version number, submitting and reviewing a pull
# request, and updating the edx-lint version reference in this repo.
# 2. install the updated version of edx-lint (in edx-lint):
#
# 3. Install the newer version of edx-lint.
# $ pip install .
#
# 4. Run:
# 3. Run (in edx-lint):
#
# # uses pylintrc_tweaks from edx-lint for linting in edx-lint
# # NOTE: Use Python 3.x, which no longer includes comments in the output file
# $ edx_lint write pylintrc
#
# 5. This will modify the local file. Submit a pull request to get it
# 4. Make a new version of edx_lint, submit and review a pull request with the
# pylintrc update, and after merging, update the edx-lint version by
# creating a new tag in the repo (uses pbr).
#
# 5. In your local repo, install the newer version of edx-lint.
#
# 6. Run:
#
# # uses local pylintrc_tweaks
# $ edx_lint write pylintrc
#
# 7. This will modify the local file. Submit a pull request to get it
# checked in so that others will benefit.
#
#
Expand Down Expand Up @@ -248,7 +259,6 @@ enable =
too-many-statements,
too-many-boolean-expressions,

ungrouped-imports,
wrong-import-order,
wrong-import-position,
wildcard-import,
Expand All @@ -273,8 +283,6 @@ disable =
too-few-public-methods,

cyclic-import,

cyclic-import,

[REPORTS]
output-format = text
Expand All @@ -301,7 +309,7 @@ docstring-min-length = 5

[FORMAT]
max-line-length = 120
ignore-long-lines = ^\s*(# )?<?https?://\S+>?$
ignore-long-lines = ^\s*(# )?((<?https?://\S+>?)|(\.\. \w+: .*))$
single-line-if-stmt = no
no-space-check = trailing-comma,dict-separator
max-module-lines = 1000
Expand Down Expand Up @@ -374,4 +382,4 @@ int-import-graph =
[EXCEPTIONS]
overgeneral-exceptions = Exception

# 9458f02180aa8dc4813a60e95bb40101d7907918
# 5c9ee962464ee40effc2a276c46143e58c629afb
10 changes: 6 additions & 4 deletions requirements/base.in
@@ -1,8 +1,10 @@
# Core requirements for using this application

-c constraints.txt
Django # Web application framework
python-dateutil # Python Date Utilities
attrs # Attributes without boilerplate
Django # Web application framework
python-dateutil # Python Date Utilities
attrs>=17.2.0 # Attributes without boilerplate
sailthru-client==2.2.3
stevedore==1.10.0
six
stevedore>=1.10.0

1 change: 0 additions & 1 deletion requirements/dev.in
Expand Up @@ -7,6 +7,5 @@ edx-lint # For updating pylintrc
edx-i18n-tools # For i18n_tool dummy
pip-tools # Requirements file management
tox # virtualenv management for tests
tox-battery==0.2 # Makes tox aware of requirements file changes; restricted by https://github.com/signalpillar/tox-battery/issues/6
twine # Utility for PyPI package uploads
wheel # For generation of wheels for PyPI

0 comments on commit 2009365

Please sign in to comment.