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

Add python tests #60

Closed
mariekers opened this issue Mar 18, 2020 · 18 comments
Closed

Add python tests #60

mariekers opened this issue Mar 18, 2020 · 18 comments
Assignees
Milestone

Comments

@mariekers
Copy link
Contributor

Make sure python code works and isn't broken by changes

Dependent on #59

Not an expert but here's some tips on writing python tests

@mariekers mariekers added this to the QA milestone Mar 18, 2020
@themightychris
Copy link
Member

themightychris commented Mar 18, 2020

I'd also consider this one done already given that you broke out #61 too -- that covers all that's left

(feel free to reopen with more detail if I'm misreading that)

@mariekers
Copy link
Contributor Author

Adding unit tests to the functions within app.py

workflow in git actions does a build check - can we do tests on individual functions?

@themightychris
Copy link
Member

A python workflow was already implemented into GitHub actions in #52:

The TODO at this point is just to actually add meaningful tests to test_app.py. What are some examples of function this issue might cover testing that would not be part of #61?

I just updated the testing section of the docs: https://codeforphilly.github.io/chime/contributing/app-dev.html#testing

@themightychris
Copy link
Member

Over here you can see how even though the current test_app.py only has one trivial assertion, that alone covers a lot of ground in at least ensuring the application and its deps can be loaded: https://github.com/CodeForPhilly/chime/pull/55/checks?check_run_id=515843837

Screen Shot 2020-03-18 at 2 09 32 PM

@garysieling
Copy link
Collaborator

I thought about this a bit, here what I would propose - this should be a pretty straightforward task for someone who knows python reasonably well.

  1. Make a test that takes runs using inputs that you can pick in the UI - assert that the model produces the same results currently. Do something like 50 randomized selections of the current inputs. This would prevent regressions.

  2. Test each input to the model for edge cases (what happens if I put in 0, a really large number, a fraction, if there are any of those)

  3. Track down the original paper for this model and write a test that replicate their results

@garysieling
Copy link
Collaborator

Possible that I've duplicated the intent of issue #61 in the above

@pjhoberman
Copy link
Collaborator

I'm going to attempt some tests here, and see if the charting functions return values so that those can be tested (since I have no idea how to make Python look at an actual visual and see if it worked...).

Question: Would you rather this be part of the github actions, or part of the developer flow (git hooks) so that devs can't even push a change without running and passing a test?

@pjhoberman pjhoberman self-assigned this Mar 18, 2020
@themightychris
Copy link
Member

@pjhoberman we already have pytest gating pull requests, so my sense is we should just start with adding tests to test_app.py

I don't think we need to mess with running it via githooks right now, devs being able to run pytest and then GitHub running that against PRs should be a great start

@themightychris themightychris changed the title Add python tests to git actions Add python tests Mar 18, 2020
@garysieling
Copy link
Collaborator

@pjhoberman since there's a range of skill level of volunteers, I think it's fine to gate at the last possible point (run tests on github before PR merges) - I don't want anyone to give up if they get tripped up on tests

@garysieling
Copy link
Collaborator

Also note based on the slack traffic there's a concurrent refactoring of app.py which would make this ticket a lot easier

@sam-writer
Copy link
Collaborator

@garysieling I think you are right, and unit testing will be easier after merging #55.

I like this suggestion. I think verifying the models and data aren't broken is most important. However, even after the refactor, there is some coupling of logic and presentation (the framework we are using, Streamlit, makes it pretty hard to fully decouple the two). So, if we want to encode the manual testing procedure, I think that sounds like a puppeteer/selenium thing to me. Or even kasaya which seems like it might be a way to get QA help from non-coders.

@garysieling
Copy link
Collaborator

Made a new ticket for Selenium type testing, I think that is a good idea as well

@mishmosh mishmosh added this to Ready in DevOps Mar 19, 2020
@pjhoberman
Copy link
Collaborator

pjhoberman commented Mar 19, 2020 via email

pjhoberman pushed a commit that referenced this issue Mar 19, 2020
pjhoberman pushed a commit that referenced this issue Mar 19, 2020
pjhoberman pushed a commit that referenced this issue Mar 19, 2020
- Removed top level __init__.py
- Added tests:
  - sim_sir
  - initial_conditions
  - derived_variables
  - new_admissions_chart
@quinn-dougherty quinn-dougherty added this to test in App Platform Mar 19, 2020
@mariekers mariekers moved this from test to Platform 1.0 Fixes in App Platform Mar 19, 2020
@mariekers mariekers reopened this Mar 19, 2020
quinn-dougherty added a commit that referenced this issue Mar 20, 2020
@pjhoberman
Copy link
Collaborator

pjhoberman commented Mar 20, 2020

  • add to test_sir including edge cases. Ensure things that shouldn't work don't work (like negative numbers in some spots) -- Add to test_sir #132
  • add more tests around sir function - need guidance from others on what should break it -- Added assertions to test_sir #151
  • add to test_sim_sirincluding edge cases. Ensure things that shouldn't work don't work (like negative numbers in some spots) -- Added assertions to test_sir #151
  • add to test_new_admissions_chart - find a way to break the chart and make sure the test captures that
  • create test_admitted_patients_chart and follow same patterns as test_new_admissions_chart

@mariekers mariekers moved this from Platform 1.0 Fixes (ready) to Platform In Progress in App Platform Mar 20, 2020
@pjhoberman pjhoberman mentioned this issue Mar 21, 2020
2 tasks
@quinn-dougherty
Copy link
Collaborator

When can we close this? it's a really broad issue

@garysieling
Copy link
Collaborator

I think it makes sense to resolve it and make smaller tickets for whatever is left- I can take a look at doing that tomorrow

@pjhoberman
Copy link
Collaborator

pjhoberman commented Mar 22, 2020 via email

@garysieling
Copy link
Collaborator

Great - I'll close this now and make tickets if there was anything I was hoping for that isn't covered

@quinn-dougherty quinn-dougherty moved this from Platform In Progress to Platform Done in App Platform Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
App Platform
Platform Done
Development

No branches or pull requests

6 participants