Skip to content

Commit

Permalink
Refactor disc prov test structure (#2108)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacsolo committed Dec 17, 2021
1 parent 7df1af4 commit 67f958f
Show file tree
Hide file tree
Showing 77 changed files with 46 additions and 45 deletions.
5 changes: 3 additions & 2 deletions discovery-provider/.vscode/settings.json
Expand Up @@ -15,9 +15,10 @@
"python.languageServer": "Pylance",
"editor.tabSize": 4,
"python.testing.pytestArgs": [
"tests"
"src",
"integration_tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true
}
}
File renamed without changes.
File renamed without changes.
Expand Up @@ -4,8 +4,8 @@
from sqlalchemy.orm.session import Session
import redis

from tests.test_get_challenges import DefaultUpdater
from tests.utils import populate_mock_db_blocks
from integration_tests.queries.test_get_challenges import DefaultUpdater
from integration_tests.utils import populate_mock_db_blocks

from src.models.models import Block
from src.models import Challenge, UserChallenge, ChallengeType
Expand Down
Expand Up @@ -18,7 +18,7 @@
from src.tasks.calculate_trending_challenges import enqueue_trending_challenges
from src.tasks.index_aggregate_plays import _update_aggregate_plays
from src.trending_strategies.trending_strategy_factory import TrendingStrategyFactory
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

REDIS_URL = shared_config["redis"]["url"]
logger = logging.getLogger(__name__)
Expand Down
File renamed without changes.
Expand Up @@ -73,7 +73,7 @@ def test_schema_missing():


def test_schema_invalid_json():
ModelValidator.BASE_PATH = "./tests/res/"
ModelValidator.BASE_PATH = "./integration_tests/res/"
try:
ModelValidator.validate(to_validate={}, field="title", model="bad")
assert False, "test_model_validator [test_schema_invalid_json] failed"
Expand All @@ -82,7 +82,7 @@ def test_schema_invalid_json():


def test_schema_missing_model_key():
ModelValidator.BASE_PATH = "./tests/res/"
ModelValidator.BASE_PATH = "./integration_tests/res/"

try:
ModelValidator.validate(to_validate={}, field="title", model="user_bad")
Expand Down
Expand Up @@ -2,7 +2,7 @@

from src.models import TagTrackUserMatview
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db


def test_track_tag_mat_view(app):
Expand Down
Expand Up @@ -19,7 +19,7 @@
from src.utils.config import shared_config
from src.tasks.index_oracles import oracle_addresses_key

from tests.test_get_challenges import setup_db
from integration_tests.queries.test_get_challenges import setup_db

REDIS_URL = shared_config["redis"]["url"]
redis_handle = redis.Redis.from_url(url=REDIS_URL)
Expand Down
@@ -1,6 +1,6 @@
from src.queries.get_track_history import _get_track_history
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

test_entities = {
"plays": [
Expand Down
Expand Up @@ -9,7 +9,7 @@
)
from src.utils.db_session import get_db

from .utils import populate_mock_db
from integration_tests.utils import populate_mock_db


entities = {
Expand Down
@@ -1,6 +1,6 @@
from src.queries.get_repost_feed_for_user import _get_repost_feed_for_user
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db


def test_get_repost_feed_for_user(app):
Expand Down
@@ -1,6 +1,6 @@
from src.queries.get_top_user_track_tags import _get_top_user_track_tags
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db


def test_get_top_user_track_tags(app):
Expand Down
Expand Up @@ -4,7 +4,7 @@
from src.queries.get_tracks import _get_tracks
from src.utils.db_session import get_db

from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db


def populate_tracks(db):
Expand Down
@@ -1,6 +1,6 @@
from src.queries.get_user_signals import _get_user_signals
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db


def make_user(
Expand Down
Expand Up @@ -3,7 +3,7 @@
from src.models import RepostType, SaveType
from src.queries.query_helpers import populate_playlist_metadata
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

logger = logging.getLogger(__name__)

Expand Down
Expand Up @@ -2,7 +2,7 @@
from src.queries import response_name_constants
from src.queries.query_helpers import populate_track_metadata
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

logger = logging.getLogger(__name__)

Expand Down
Expand Up @@ -2,7 +2,7 @@
from src.queries import response_name_constants
from src.queries.query_helpers import populate_user_metadata
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
@@ -1,7 +1,7 @@
from src.queries.search_track_tags import search_track_tags
from src.utils.db_session import get_db
from src.tasks.index_aggregate_plays import _update_aggregate_plays
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db


def test_search_track_tags(app):
Expand Down
@@ -1,6 +1,6 @@
from src.queries.search_user_tags import search_user_tags
from src.utils.db_session import get_db
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db


def test_search_user_tags(app):
Expand Down
Expand Up @@ -2,7 +2,7 @@
from src.models import Challenge, UserChallenge, ChallengeType, User
from src.utils.db_session import get_db
from src.queries.get_undisbursed_challenges import get_undisbursed_challenges
from tests.utils import populate_mock_db_blocks
from integration_tests.utils import populate_mock_db_blocks


def setup_challenges(app):
Expand Down
Expand Up @@ -6,7 +6,7 @@
from src.models import AggregatePlays
from src.utils.config import shared_config
from src.utils.db_session import get_db
from .utils import populate_mock_db
from integration_tests.utils import populate_mock_db

REDIS_URL = shared_config["redis"]["url"]

Expand Down
Expand Up @@ -13,7 +13,7 @@
from src.utils.config import shared_config
from src.utils.redis_cache import set_json_cached_key
from src.tasks.index_aggregate_plays import _update_aggregate_plays
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

REDIS_URL = shared_config["redis"]["url"]
DEFAULT_EVENT = ""
Expand Down
Expand Up @@ -6,7 +6,7 @@
from src.utils.playlist_event_constants import playlist_event_types_lookup
from src.utils import helpers
from src.challenges.challenge_event_bus import setup_challenge_bus
from tests.index_helpers import AttrDict, IPFSClient, UpdateTask
from integration_tests.challenges.index_helpers import AttrDict, IPFSClient, UpdateTask

block_hash = b"0x8f19da326900d171642af08e6770eedd83509c6c44f6855c98e6a752844e2521"

Expand Down
Expand Up @@ -13,7 +13,7 @@
from src.utils.config import shared_config
from src.utils.db_session import get_db

from .utils import populate_mock_db
from integration_tests.utils import populate_mock_db

REDIS_URL = shared_config["redis"]["url"]

Expand Down
Expand Up @@ -11,7 +11,7 @@
from src.utils.redis_connection import get_redis
from src.solana.solana_client_manager import SolanaClientManager

from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

REWARDS_MANAGER_PROGRAM = shared_config["solana"]["rewards_manager_program_address"]
REWARDS_MANAGER_ACCOUNT = shared_config["solana"]["rewards_manager_account"]
Expand Down
Expand Up @@ -12,7 +12,7 @@
from src.utils import helpers
from src.utils.db_session import get_db
from src.challenges.challenge_event_bus import ChallengeEventBus, setup_challenge_bus
from tests.index_helpers import AttrDict, IPFSClient, UpdateTask
from integration_tests.challenges.index_helpers import AttrDict, IPFSClient, UpdateTask

block_hash = b"0x8f19da326900d171642af08e6770eedd83509c6c44f6855c98e6a752844e2521"

Expand Down
Expand Up @@ -8,7 +8,7 @@
)
from src.utils.config import shared_config
from src.utils.db_session import get_db
from .utils import populate_mock_db
from integration_tests.utils.utils import populate_mock_db

REDIS_URL = shared_config["redis"]["url"]

Expand Down
Expand Up @@ -11,7 +11,7 @@
from src.utils.redis_connection import get_redis
from src.utils.user_event_constants import user_event_types_lookup

from tests.index_helpers import AttrDict, IPFSClient
from integration_tests.challenges.index_helpers import AttrDict, IPFSClient

block_hash = b"0x8f19da326900d171642af08e6770eedd83509c6c44f6855c98e6a752844e2521"

Expand Down
Expand Up @@ -7,7 +7,7 @@
TrendingTracksStrategyaSPET,
)
from src.tasks.index_aggregate_plays import _update_aggregate_plays
from tests.utils import populate_mock_db
from integration_tests.utils import populate_mock_db

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
File renamed without changes.
Expand Up @@ -6,17 +6,17 @@

import src.utils.multihash
from src.utils.helpers import remove_test_file
from tests.utils import query_creator_by_name, to_bytes
from integration_tests.utils import query_creator_by_name, to_bytes


@pytest.mark.skip(
reason="user contract functions changed, skipping now to unblock dependent work until fixed"
)
def test_index_operations(app, client, celery_app, contracts):
"""Confirm indexing of creator operations results in expected state change"""
test_file = "tests/res/test_audio_file.mp3"
creator_metadata_json_file = "tests/res/test_creator_metadata.json"
track_metadata_json_file = "tests/res/test_track_metadata.json"
test_file = "integration_tests/res/test_audio_file.mp3"
creator_metadata_json_file = "integration_tests/res/test_creator_metadata.json"
track_metadata_json_file = "integration_tests/res/test_track_metadata.json"

user_factory_contract = contracts["user_factory_contract"]
track_factory_contract = contracts["track_factory_contract"]
Expand Down
Expand Up @@ -10,7 +10,7 @@

IPFS_FETCH = 'get_metadata_from_ipfs_node'
GATEWAY_FETCH = 'get_metadata_from_gateway'
JSON_FILE = "tests/res/test_ipfs.json"
JSON_FILE = "integration_tests/res/test_ipfs.json"

# Helpers
def get_ipfs_client(app):
Expand Down
2 changes: 1 addition & 1 deletion discovery-provider/scripts/lint.sh
@@ -1,5 +1,5 @@
set -e

pylint src/
pylint tests/
pylint integration_tests/
mypy --ignore-missing-imports --follow-imports=silent --show-column-numbers src/
2 changes: 1 addition & 1 deletion discovery-provider/scripts/test.sh
Expand Up @@ -71,4 +71,4 @@ sleep 5
pytest src

# Integration tests
pytest tests
pytest integration_tests
2 changes: 0 additions & 2 deletions discovery-provider/src/queries/get_app_name_metrics_test.py

This file was deleted.

@@ -0,0 +1,2 @@
def test():
"""See /integration_tests/test_get_app_name_metrics.py"""
2 changes: 0 additions & 2 deletions discovery-provider/src/queries/get_genre_metrics_test.py

This file was deleted.

2 changes: 2 additions & 0 deletions discovery-provider/src/queries/get_genre_metrics_unit_test.py
@@ -0,0 +1,2 @@
def test():
"""See /integration_tests/test_get_genre_metrics.py"""
2 changes: 0 additions & 2 deletions discovery-provider/src/queries/get_plays_metrics_test.py

This file was deleted.

2 changes: 2 additions & 0 deletions discovery-provider/src/queries/get_plays_metrics_unit_test.py
@@ -0,0 +1,2 @@
def test():
"""See /integration_tests/test_get_plays_metrics.py"""
2 changes: 0 additions & 2 deletions discovery-provider/src/queries/get_route_metrics_test.py

This file was deleted.

2 changes: 2 additions & 0 deletions discovery-provider/src/queries/get_route_metrics_unit_test.py
@@ -0,0 +1,2 @@
def test():
"""See /integration_tests/test_get_route_metrics.py"""

0 comments on commit 67f958f

Please sign in to comment.