Skip to content

Conversation

@gribok
Copy link
Contributor

@gribok gribok commented Mar 17, 2020

Based on #64, I created a basic test suite with following features:

  • Unit-Testing of all help function, like date.is_date
  • Integration-Testing of API endpoints (validation agains output from tests/expected_output)
  • Add example data to tests/example_data for testing
  • Mocking of app.data.requests.get and app.data.datetime to enforce data fetch locally from tests/example_data
  • Edit of README.md for testing and linting
  • Add pytest and pytest to Pipfile to dev-packages
  • Randomize testing possible to test for stable code
  • Update Pipfile.lock with new dev-dependencies

Testing of PR:

$ pytest -s -v tests/

ToDos:

  • Add additonal testcases for endpoint /all. It is hard to test due to caching mechanism. Need to check, if it is possible to deactivate caching during testing
  • Optional: Contol testing per Makefile
  • Optional: Add to CI-pipeline

@ExpDev07
Copy link
Owner

This is gonna conflict with /v2/: https://github.com/ExpDev07/coronavirus-tracker-api/tree/v2 😢

@gribok
Copy link
Contributor Author

gribok commented Mar 18, 2020

No problem. I will waiting for release of v2 and adapt the testcases

@ExpDev07
Copy link
Owner

@gribok Really appreciate it.

@ExpDev07
Copy link
Owner

You should be good to make your edits now :). /v2/ is released.

Copy link
Owner

@ExpDev07 ExpDev07 left a comment

Choose a reason for hiding this comment

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

Is it necessary to have testing for legacy endpoints? Shouldn't we rather focus on maintaining testing for the new /v2/ endpoints??

from unittest import mock
import pytest

from app import data
Copy link
Owner

Choose a reason for hiding this comment

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

The data module no longer exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already obsolet. Accidentally push commits to early. :-)

@ExpDev07
Copy link
Owner

Conflicts needed to be resolved.

@gribok
Copy link
Contributor Author

gribok commented Mar 18, 2020

Fixed all merge conflicts.
Adapt testsuite to v2.

Check it out. :-)

Some points to highlights;

  • Due to cache mechanism, it is important to mock same datetime for latest key
    • Create constant variable test_jhu.DATETIME_STRING
  • Return data of API endpoints validate against expected output for /v1 and /v2 endpoints

Would be nice, to be added to contrib-list

@ExpDev07
Copy link
Owner

Looks good sir.

@ExpDev07 ExpDev07 merged commit d6330e4 into ExpDev07:master Mar 18, 2020
@ExpDev07
Copy link
Owner

@all-contributors please add @gribok for code and testing.

@allcontributors
Copy link
Contributor

@ExpDev07

I've put up a pull request to add @gribok! 🎉

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.

2 participants