Jaffa / amazon-music

Provide programmatic access to Amazon Music/Prime Music's streaming service
Apache License 2.0
336 stars 67 forks source link

Add travis ci to write software tests #4

Open danieldaeschle opened 6 years ago

danieldaeschle commented 6 years ago

Maybe after writing some tests you can add travis ci? :)

Jaffa commented 6 years ago

Yep. Big fan of automated testing; is there an introduction to unit testing in Python you can recommend?

danieldaeschle commented 6 years ago

I don't know an introduction at the moment. But my default preferences are:

Install pytest for run tests with pytest command Install pytest-sugar for nicer output. Use pytest -p no:sguar to run it with default output

Directory called tests

which includes:

conftest.py

import pytest

@pytest.fixture
def am():
    return AmazonMusic(...)

my_test.py

def test_sth(am):
    albums = am.list_albums()
    assert len(albums) > 0

Here is the documentation

But to write tests, we have to insert credentials. This can be a little bit diffcult to solve...