musicfox / pycmc

A Python interface for the chartmetric.com API
MIT License
21 stars 2 forks source link

Cleanup and fix failing tests #6

Closed thinkjrs closed 4 years ago

thinkjrs commented 4 years ago

Some of our tests have been failing for a while and there were a few deprecations upstream since I've worked on this client.

Update deprecated tests

image

Fix failing tests

Or comment & explain failing tests & remove functionality

  1 tests/test_album.py::test_charts FAILED                                  [  1%]
  2 tests/test_artist.py::test_charts FAILED                                 [ 13%]
  3 tests/test_charts.py::test_amazon_tracks FAILED                          [ 31%]
  4 tests/test_charts.py::test_amazon_albums FAILED                          [ 32%]
  5 tests/test_charts.py::test_cm_score_tracks FAILED                        [ 39%]
  6 tests/test_charts.py::test_cm_score_artists FAILED                       [ 40%]
  7 tests/test_charts.py::test_cm_score_albums FAILED                        [ 42%]
  8 tests/test_charts.py::test_youtube_artists FAILED                        [ 59%]
  9 tests/test_playlist.py::test_evolution FAILED                            [ 80%]
 10 tests/test_playlist.py::test_lists FAILED                                [ 81%]
 11 tests/test_track.py::test_charts FAILED                                  [ 88%]
 12 tests/test_track.py::test_get_track_ids FAILED                           [ 89%]

Cleanup tests

Our tests need a number of new things:

In addition, our current tests need updating: ~- [ ] add modern type hints~

thinkjrs commented 4 years ago

test_album.py::test_charts

Working! And..not working! What?

Something's happening to auth as we're getting 403's when using certain dates. However, if sticking to exactly those combinations used in the documentation tests will pass.

I recommend putting a logging.warning in .artist.charts, for now.

What was changed?

The "until" date--we used 2020 in the failing and 2019 in the passing.

The error

image

Passing!

image

thinkjrs commented 4 years ago

Added a slowdown and code coverage in commit c6befd10f and de6381bc467 .

thinkjrs commented 4 years ago

Better testing combos

Commentary for more cohesive testing of api combinations, above.

Map key:value pairs

Essentially, we need to grab the possible keys from the chartmetric documentation for each endpoint and then for each key list their possible values.

Randomize the ids used

We should also have a "randomizer" for ids used for testing, controlled from a single place. As in:


pytest.fixture(scope='module')
def getTestData():
    return dict(
         test_artists =  ['artist1cmid', 'artist2cmid'],
        test_tracks = [...],
        test_somethingWithAnID = [...],
    )

pytest.fixture(scope='module')
def data(getTestData):
    return dict(
        test_artist=random.choice(getTestData['test_artists']),
        ...,
    )
thinkjrs commented 4 years ago

Also, coverage: image

thinkjrs commented 4 years ago

Okay, so the coverage above included our test coverage for tests, as I forgot to exclude the tests/ dir in the configuration: coverage image

Much, much better, and closer to what's expected.