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

new unit test module for auth_handlers.py #611

Merged
merged 5 commits into from
Jul 26, 2018

Conversation

sjanssen2
Copy link
Contributor

My first try to add proper unit tests for a handler class. All comments are appreciated.

@sjanssen2
Copy link
Contributor Author

@wasade @ElDeveloper @josenavas could you please look into the Travis error. I have the feeling that it is not related to my unit tests.

@wasade
Copy link
Member

wasade commented Sep 6, 2016

Weird... either a config entry changed or something in the BG text? Not
seeing it in changes (or I'm blind) yet master is not having this issue?

On Tue, Sep 6, 2016 at 6:26 PM, Stefan Janssen [email protected]
wrote:

@wasade https://github.com/wasade @ElDeveloper
https://github.com/ElDeveloper @josenavas https://github.com/josenavas
could you please look into the Travis error. I have the feeling that it is
not related to my unit tests.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#611 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAc8shvP9lV9u50vNNaOY9EhE8ZQdwLkks5qnaJUgaJpZM4J2EpD
.

@sjanssen2
Copy link
Contributor Author

Master is having the same problem: #612 (I only added an empty file). @EmbrietteH are you aware of any config changes?

@EmbrietteH
Copy link
Contributor

Not that I am aware of...

@sjanssen2
Copy link
Contributor Author

found the bug: its a ’ character in the SHIPPING_ADDRESS of amgut/lib/locale_data/british_gut.py line 86.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.4%) to 65.026% when pulling 459578e on sjanssen2:unittest-auth_handlers into c98793e on biocore:master.

@sjanssen2
Copy link
Contributor Author

@wasade @josenavas @EmbrietteH now that Travis passes, I am happy to get some feedback about my first unit test for AG.

(port, url_escape(text_locale['handlers']['INVALID_KITID'])))

unregistered_kits = ag_data.get_all_handout_kits()
if len(unregistered_kits) <= 0:
Copy link
Member

Choose a reason for hiding this comment

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

if you are modifying the database, you should add a tearDown method in the test class that reverts those changes. If you do that, this error will never be raised, so you can remove this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I don't know how I can undo the changed. I have the feeling that there is no python method to undo this specific operation, thus I need to operate on the database myself or revert the complete database?! Any suggestions how I should proceed here?

Copy link
Member

Choose a reason for hiding this comment

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

@josenavas, in the CI environment, the database is reset on every build, and on a local system, this would require probably thousands of runs before its an issue, right?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure - but I'm more concerned if a change in the order of the tests is going to fire up a stochastic failure. If we don't foresee this issue, what we can do is open an issue, put a TODO comment on the code with the link to the issue and try to fix later, so we don't loose track of that. I don't know from the top of my head how to revert this changes in the database, as that is specific to the code being executed, but I was told that in this repository, instead of reseting the full database in each test, the local changes are reverted

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 dived into the SQL code. When a kit is registered to an user, the kit is inserted into the table ag_kit and removed from the table ag_handout_kits. During this process, we loose the information in column "created_on". Thus, I cannot revert this function.
To have the DB in the same state as before the test, I would need to write code which anticipates what is going to happen, store the information which is going to be lost somewhere else, perform the SQL operation which I want to test, and create a new function which takes the otherwise stored information to revert the tested SQL operation. This sounds not only quite complicated, but surely introduces potential mistakes + the need to keep code in sync.
What shall I do??

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for taking a look @sjanssen2 !! I think for the time being you can create a new issue, and put a comment in the code: #TODO: see issue #XXX so we can keep track of it.

I think at some point we can do something like what we are doing on Qiita ATM, reset the DB on each class (rather than test), but I think this will need a longer discussion.

Copy link
Contributor Author

@sjanssen2 sjanssen2 Sep 16, 2016

Choose a reason for hiding this comment

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

I opened the issue #618 and added a TODO comment in the code

@josenavas
Copy link
Member

Thanks @sjanssen2 minor comments!

@coveralls
Copy link

Coverage Status

Coverage increased (+2.4%) to 65.079% when pulling 654f69d on sjanssen2:unittest-auth_handlers into 8880951 on biocore:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.4%) to 65.079% when pulling 86e4e9b on sjanssen2:unittest-auth_handlers into 8880951 on biocore:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+2.4%) to 65.079% when pulling 023411b on sjanssen2:unittest-auth_handlers into 8880951 on biocore:master.

Copy link
Member

@wasade wasade left a comment

Choose a reason for hiding this comment

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

Still getting familiar with the new gh review system

@wasade wasade merged commit b8f4059 into biocore:master Jul 26, 2018
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.

5 participants