hedyhli / starcli

:sparkles: Browse trending GitHub projects from your command line
https://pypi.org/project/starcli/
MIT License
550 stars 50 forks source link

Add CLI tests (pytest) to test the CLI itself #41

Closed hedyhli closed 4 years ago

hedyhli commented 4 years ago

Currently we only have a search() test (you can check out the tests dir), we probably need a way to emulate a real terminal and call it from that command line (With different options) to test the full functionality, can use: https://click.palletsprojects.com/en/7.x/testing/

Just add some test_*.py files in tests/ and in it add test_* functions to do your test. Then you can run python -m pytest and make sure they pass. We need these because they are part of the GitHub action workflow, all pull request and pushed commits will then be tested using it

Chalmiller commented 4 years ago

Hi there,

I'd like to take on this issue if that's okay?

hedyhli commented 4 years ago

@Chalmiller Sure, of course it's okay :)

hedyhli commented 4 years ago

Just found this: https://click.palletsprojects.com/en/7.x/testing/ We can use that for testing CLI 👍🏻

jSadoski commented 4 years ago

Hi @Chalmiller, are you still working on this? Are you using the Click testing as @hedythedev suggested? I'd like to work on this issue as well.

hedyhli commented 4 years ago

Looks like @Chalmiller hasn't responded or forked, I'll add you instead @jSadoski 😉

jSadoski commented 4 years ago

So I've implemented a basic testing suite based on click.testing which tests every parameter and passes. The issue I'm having now, however, is hitting the rate limits as described in #61 on just my test file alone, not to mention when running all the tests. Running each test independently works, just not one right after the other.

The key indicator of this problem is when

https://github.com/hedythedev/starcli/blob/0e9da5fe73b78b6dd4ffd8b465011b22806624ad/starcli/search.py#L133

returns <Result KeyError('items')>

Short of building in a delay if this error occurs, I'm not sure what to do about it until #61 is resolved.

hedyhli commented 4 years ago

Not sure if it's possible to add API keys so we have a higher rate limit