Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing and quality upgrades #123

Merged
merged 4 commits into from
Feb 15, 2018
Merged

Testing and quality upgrades #123

merged 4 commits into from
Feb 15, 2018

Conversation

bmedx
Copy link
Contributor

@bmedx bmedx commented Feb 13, 2018

  • Move to pytest
  • Move to pycodestyle
  • Move to codecov
  • Use edx-pylint
  • Fixup for associated issues

Still to do: Clean up requirements, implement pip-compile

- Also disables Python 3 checks as there are many issues that will
need to be addressed when the time comes to upgrade.
@bmedx bmedx force-pushed the bmedx/test_and_quality_upgrades branch from e532c5e to 22d5509 Compare February 14, 2018 21:08
.tox
.pytest_cache

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that's a recent improvement: pytest-dev/pytest#3138 . Used to be .cache, which made it unclear at a glance where it was coming from.

known_first_party =
workbench
sample_xblocks
sections = FUTURE,STDLIB,THIRDPARTY,DJANGO,DJANGOAPP,EDX,FIRSTPARTY,LOCALFOLDER

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably standardize on an order for these pretty soon; I think the cookiecutter and edx-platform still conflict (this looks like the cookiecutter order).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This is the cookiecutter version, which I tend to use as the canonical way of doing things for these app / xblock repos (for better or worse, I just want things to be as consistent as they can be).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh - not looking forward to going back into edx-platform and running isorts again....


script:
- tox

after_success:
- "pip install coveralls"
- "coveralls"
- codecov

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has devops enabled codecov integration for the repo yet?

Copy link
Contributor Author

@bmedx bmedx Feb 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was waiting to see if it fired off a hook, but never did so I'll file a ticket. Edit: filed as DEVOPS-7164


install:
- "pip install tox-travis"
- pip install tox-travis
- pip install -r requirements/tox.txt

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be fixed right now, but the pip-tools PR should generate a travis.txt or such which includes tox-travis.

.PHONY: cover
cover:
coverage run manage.py test
coverage report

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep a target for generating the coverage report? The cookiecutter has one that launches the HTML report in a browser window.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a version of it in the next round of changes, which pulls in most of the cookiecutter Makefile. Once this goes in I'll make a new branch of those changes and push it so whoever gets to this next has a starting place a little further along.

from mock import Mock
from xblock.runtime import DictKeyValueStore, KvsFieldData
from xblock.test.tools import TestRuntime, assert_equals, assert_in
from xblock.test.tools import TestRuntime as TR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, what prompted using this alias?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pytest was trying to collect it as a test due to the name and was throwing a warning about it having an init. It should really be renamed in xblock, but I'm already pretty far afield in doing this PR. I'll comment it to explain.

setup.cfg Outdated
@@ -9,8 +9,5 @@ rednose=1
[pep8]
exclude=src/,.*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the pycodestyle section in tox.ini, do we still need this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, will remove.

tox.ini Outdated
django111: Django>=1.11,<1.12
passenv =
DISPLAY
commands =
make var/workbench.db
make test
py.test {posargs}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"pytest" has been recommended over "py.test" since the 3.0.0 release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update it here, but this actually came in from the cookiecutter template so we should fix it there too.


from workbench import scenarios
from workbench.runtime_util import reset_global_state

pytestmark = pytest.mark.django_db # pylint: disable=invalid-name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually being used? Same question on the other files defining it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, from what I read it's the best practice way to get db access under pytest_django so that we're explicit about which tests hit the database. If we know of a better way of doing this I'm happy to change the pattern, though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'd missed the docs on applying a mark to an entire module. Good to know.

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "workbench.settings")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this actually does need to come before the get_wsgi_application import; there's a from django.conf import settings in one of the indirectly imported modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, an overzealous isort.

@bmedx
Copy link
Contributor Author

bmedx commented Feb 15, 2018

@jmbowman @doctoryes I think all of the applicable feedback has been addressed. Should be good for re-review.

known_first_party =
workbench
sample_xblocks
sections = FUTURE,STDLIB,THIRDPARTY,DJANGO,DJANGOAPP,EDX,FIRSTPARTY,LOCALFOLDER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh - not looking forward to going back into edx-platform and running isorts again....

@bmedx bmedx merged commit 48cb0d5 into master Feb 15, 2018
@bmedx bmedx deleted the bmedx/test_and_quality_upgrades branch February 15, 2018 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants