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

Migrate from nose to pytest #24

Merged
merged 1 commit into from
Sep 10, 2021
Merged

Conversation

ghassanmas
Copy link
Member

Fixes (Partially) : edx/upgrades#68

@ghassanmas ghassanmas requested a review from a team September 1, 2021 15:13
@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Sep 1, 2021
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 1, 2021

Thanks for the pull request, @ghassanmas! I've created OSPR-6010 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

Copy link
Contributor

@stvstnfrd stvstnfrd left a comment

Choose a reason for hiding this comment

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

@ghassanmas Here are some quick thoughts.

Note that tests are failing, so we'll need to sort that out ;)

Also, I upgraded this repo to Github Actions (from Travis-CI) this morning, so that should get picked up when you rebase/push again.

invideoquiz/settings.py Outdated Show resolved Hide resolved
invideoquiz/settings.py Outdated Show resolved Hide resolved
@stvstnfrd
Copy link
Contributor

@ghassanmas It looks like there are also references to nose inside setup.cfg;
we should remove those too.

@ghassanmas ghassanmas marked this pull request as draft September 2, 2021 13:39
@ghassanmas
Copy link
Member Author

@stvstnfrd I have resolved your comments, and sycned/merged with your latest push as well.
So now the siuation is, tox is falling, but before digging into the problem should we first make sure that the envlist that tox needs to check against are correct?

@ghassanmas
Copy link
Member Author

ghassanmas commented Sep 2, 2021

The tox tests fail except for quality because there are currently no tests to run, when pytest runs 0 tests, it exit with code 5, ref doc. Sample error output when running tox in my machine:

ERROR: InvocationError for command /xblock-in-video-quiz/.tox/py38-django30/bin/pytest (exited with code 5)

So to move forward I suppose we would either try to do a hacky thing, check this or run actual tests!

@ghassanmas ghassanmas marked this pull request as ready for review September 2, 2021 14:50
@natabene
Copy link

natabene commented Sep 3, 2021

@ghassanmas Thank you for your contribution. @stvstnfrd Do you plan to review this or should I reach out to Sarina about assigning this one?

@ghassanmas
Copy link
Member Author

My pleasure @natabene :)
@stvstnfrd I have just added a test case which tests for the Xblock initial deafult field value, that being said, now running tox shuold succeed

Copy link
Contributor

@sarina sarina left a comment

Choose a reason for hiding this comment

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

This looks good to me - left a few nits I'd like addressed. Could you also please squash your commits and use conventional commits? You'll also need to rebase your branch.

key_store = DictKeyValueStore()
field_data = KvsFieldData(key_store)
runtime = Runtime(services={'field-data': field_data})
instace = InVideoQuizXBlock(runtime, scope_ids=Mock())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could this variable be named instance?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd second this request, and even call it not a "nit"; misspelled words/variables should always be corrected ("nit" implies an optional request)

from unittest.mock import Mock


def test_invideoquiz_view():
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could you add a docstring that explains what is being tested?

Copy link
Contributor

@stvstnfrd stvstnfrd left a comment

Choose a reason for hiding this comment

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

This generally looks good and I second @sarina 's comments.

Since the previous (empty) test files are no longer applicable, would you mind removing them?

git rm invideoquiz/tests.py invideoquiz/tests/test_travis.py

key_store = DictKeyValueStore()
field_data = KvsFieldData(key_store)
runtime = Runtime(services={'field-data': field_data})
instace = InVideoQuizXBlock(runtime, scope_ids=Mock())
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd second this request, and even call it not a "nit"; misspelled words/variables should always be corrected ("nit" implies an optional request)

@sarina
Copy link
Contributor

sarina commented Sep 9, 2021

@ghassanmas this now looks good to me but I cannot merge until you resolve conflicts by rebasing, and you squash your commits and use conventional commits. https://open-edx-proposals.readthedocs.io/en/latest/oep-0051-bp-conventional-commits.html

If you need help with these, please let us know.

@sarina
Copy link
Contributor

sarina commented Sep 9, 2021

@ghassanmas Instructions to rebase and squash are here: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request

this commit is part of part of supporting Django 3.2
upgrade, for more context: edx/upgrades#68, the changes are:
1. Removing nose as a tool for testing
2. Adding pytest as the alternative
3. Updating the requirments to reflect 1 and 2
4  Adding a test which tests the deafult value of the Xblock model
@ghassanmas
Copy link
Member Author

@sarina Thank you for the info, took little of time to get my head around rebase, gonna keep rewriting history from now on! 😁

Copy link
Contributor

@stvstnfrd stvstnfrd left a comment

Choose a reason for hiding this comment

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

+1 from me, thanks @ghassanmas !

@openedx-webhooks
Copy link

@ghassanmas 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged open-source-contribution PR author is not from Axim or 2U
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants