scikit-build / github-release

Manage github releases from the command line
Apache License 2.0
56 stars 22 forks source link

Use Betamax to implement tests #11

Open jcfr opened 7 years ago

jcfr commented 7 years ago

The plan is to leverage tools like betamax allowing to intercept every request made and attempting to find a matching request that has already been intercepted and recorded.

See http://betamax.readthedocs.io/

jcfr commented 6 years ago

@Pierre-Assemat : When you have a chance, let me know what would you suggest to improve the testing.

Pierre-Assemat commented 6 years ago

In Slicer Package Manager PR we use pytest-vcr to intercepted and recorded the server responses.

It works well and is very easy to use. Just by adding the decorator @pytest.mark.vcr() on top of each one of your test you'd like to record the server responses, like for instance:

@pytest.mark.vcr()
def test_main():
    import github_release as ghr
    with pytest.raises(SystemExit) as exc_info:
        ghr.main()
assert exc_info.code == 0

Running the test for the first time will create a folder cassettes in path/to/folder/github-release/tests which will contain a file.yml for each tests decorate by @pytest.mark.vcr().

For more information about this feature see the pytest-vcr docs

I think you could try to use that and see if it's compatible your testing. I could create a PR and try if you want!