New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CB-231: Support for testing MusicBrainz-dependent code #134
Conversation
docker/docker-compose.dev.yml
Outdated
@@ -49,3 +50,12 @@ services: | |||
MB_IMPORT_DUMPS: "true" | |||
ports: | |||
- "5430:5432" | |||
|
|||
musicbrainz_test_db: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible here to use https://hub.docker.com/r/metabrainz/musicbrainz-test-database/ ? (users already have it downloaded so that they can run the musicbrainz database)
2b38b8f
to
ad90374
Compare
I've updated the dockerfiles for using the |
The following entities are present in the test data: Release Groups: (and their corresponding releases(with media, recordings) and tags)
Artists: (with tags)
Place
Event
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the function of the critiquebrainz.conftest
module? Can you add some docstrings for not very obvious functions and modules describing what their purpose is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes way too long to start the MusicBrainz test database for some reason. https://gist.github.com/anonymous/03fad617d32fff4268ae9dce59036aae
This is a big problem since tests should run as fast as possible. I'd suggest considering writing mock functions for accessing MB data since we have so many services running in the dev/test environment already.
c840795
to
4908a73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check that the changes in critiquebrainz/frontend/external/musicbrainz_db/place.py actually need to be there?
from flask_testing import TestCase | ||
from critiquebrainz.frontend import create_app | ||
|
||
class MBDatabaseTestCase(TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this base class need to be based on flask_testing
's TestCase or a regular one from unittest
would be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, flask_testing
's TestCase is required as it sets up the critiquebrainz_redis
container for the tests. I get the following error when using unittest.TestCase
> https://gist.github.com/ferbncode/2a3f3967015747c45efedfc20b7f3608. But this can be avoided by initializing redis separately in the setUp
functions. Please suggest which method is preferred. Thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If creating a whole Flask app is unnecessary then I'd say it's better to just initialise the cache module.
import critiquebrainz.frontend.external.musicbrainz_db as mb | ||
from critiquebrainz.frontend.external.musicbrainz_db.test_data import linkplaceurl_1, linkplaceurl_2, place_suisto | ||
|
||
class HelpersTestClass(MBDatabaseTestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HelpersTestCase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some improvements to be made, but feel free to submit that separately.
|
||
REDIS_HOST = 'critiquebrainz_redis' | ||
REDIS_PORT = 6379 | ||
REDIS_NAMESPACE = 'CB' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is not ideal. It would be good to get these values from the test configuration instead.
Added tests for
place
entity andsample_data.py
which contains all the test data. Presently, the tests take quite sometime to run (working on it).