-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into rj-coinflow-purchase-vendor
- Loading branch information
Showing
87 changed files
with
3,689 additions
and
1,248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"version": "0.6.121", | ||
"version": "0.6.122", | ||
"service": "content-node" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"version": "0.6.121", | ||
"version": "0.6.122", | ||
"service": "discovery-node" | ||
} |
83 changes: 83 additions & 0 deletions
83
packages/discovery-provider/integration_tests/tasks/test_get_top_playlists_es.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import logging | ||
import os | ||
import subprocess | ||
import time | ||
|
||
from elasticsearch import Elasticsearch | ||
|
||
from integration_tests.utils import populate_mock_db | ||
from src.queries.get_top_playlists_es import get_top_playlists_es | ||
from src.utils.db_session import get_db | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
esclient = Elasticsearch(os.environ["audius_elasticsearch_url"]) | ||
|
||
entities = { | ||
"users": [{"user_id": 1}, {"user_id": 2}, {"user_id": 3}], | ||
"follows": [ | ||
{"follower_user_id": 1, "followee_user_id": 2}, | ||
], | ||
"tracks": [ | ||
{"track_id": 1, "owner_id": 2, "genre": "Electronic"}, | ||
{"track_id": 2, "owner_id": 3, "genre": "Electronic"}, | ||
], | ||
"playlists": [ | ||
{ | ||
"playlist_id": 1, | ||
"playlist_owner_id": 2, | ||
"playlist_contents": {"track_ids": [{"track": 1, "time": 1}]}, | ||
}, | ||
{ | ||
"playlist_id": 2, | ||
"playlist_owner_id": 3, | ||
"playlist_contents": {"track_ids": [{"track": 2, "time": 2}]}, | ||
}, | ||
], | ||
} | ||
|
||
|
||
def setup_db(app): | ||
with app.app_context(): | ||
db = get_db() | ||
|
||
populate_mock_db(db, entities) | ||
|
||
time.sleep(1) | ||
logs = subprocess.run( | ||
["npm", "run", "catchup:ci"], | ||
env=os.environ, | ||
capture_output=True, | ||
text=True, | ||
cwd="es-indexer", | ||
timeout=30, | ||
) | ||
logging.info(logs) | ||
esclient.indices.refresh(index="*") | ||
search_res = esclient.search(index="*", query={"match_all": {}})["hits"]["hits"] | ||
assert len(search_res) == 7 | ||
|
||
|
||
def test_get_top_playlists(app): | ||
setup_db(app) | ||
|
||
with app.app_context(): | ||
playlists = get_top_playlists_es( | ||
"playlist", {"current_user_id": 1, "limit": 10} | ||
) | ||
# user 1 should see all top playlists | ||
assert len(playlists) == 2 | ||
assert playlists[0]["playlist_id"] == 1 | ||
assert playlists[1]["playlist_id"] == 2 | ||
|
||
|
||
def test_get_top_followee_playlists(app): | ||
setup_db(app) | ||
|
||
with app.app_context(): | ||
playlists = get_top_playlists_es( | ||
"playlist", {"current_user_id": 1, "limit": 10, "filter": "followees"} | ||
) | ||
# assert user 1 only sees playlists from who they follow (user 2) | ||
assert len(playlists) == 1 | ||
assert playlists[0]["playlist_id"] == 1 |
Oops, something went wrong.