Skip to content

Commit

Permalink
Fix to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ManiMatter committed Feb 18, 2024
1 parent 85a8d6f commit 4fdb6ee
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
13 changes: 6 additions & 7 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
requests
aiohttp
asyncio
python-dateutil
verboselogs
pytest
pytest-asyncio
requests==2.31.0
asyncio==3.4.3
python-dateutil==2.8.2
verboselogs==1.7
pytest==8.0.1
pytest-asyncio==0.23.5
2 changes: 1 addition & 1 deletion src/remove_slow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ async def remove_slow(settings_dict, BASE_URL, API_KEY, NAME, deleted_downloads,
# Detects slow downloads and triggers delete. Adds to blocklist
try:
failType = 'slow'
logger.debug('remove_slow/queue IN: %s', formattedQueueInfo(queue))
queue = await get_queue(BASE_URL, API_KEY)
logger.debug('remove_slow/queue IN: %s', formattedQueueInfo(queue))
if not queue: return 0
# Find items affected
affectedItems = []
Expand Down
2 changes: 1 addition & 1 deletion src/remove_stalled.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ async def remove_stalled(settings_dict, BASE_URL, API_KEY, NAME, deleted_downloa
# Detects stalled and triggers repeat check and subsequent delete. Adds to blocklist
try:
failType = 'stalled'
logger.debug('remove_stalled/queue IN: %s', formattedQueueInfo(queue))
queue = await get_queue(BASE_URL, API_KEY)
logger.debug('remove_stalled/queue IN: %s', formattedQueueInfo(queue))
if not queue: return 0
# Find items affected
affectedItems = []
Expand Down
2 changes: 1 addition & 1 deletion src/remove_unmonitored.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ async def remove_unmonitored(settings_dict, BASE_URL, API_KEY, NAME, deleted_dow
# Removes downloads belonging to movies/tv shows that are not monitored. Does not add to blocklist
try:
failType = 'unmonitored'
logger.debug('remove_unmonitored/queue IN: %s', formattedQueueInfo(queue))
queue = await get_queue(BASE_URL, API_KEY)
logger.debug('remove_unmonitored/queue IN: %s', formattedQueueInfo(queue))
if not queue: return 0
# Find items affected
monitoredDownloadIDs = []
Expand Down
9 changes: 2 additions & 7 deletions tests/test_nest_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pytest tests

# python3 -m pytest
import pytest
from src.utils.nest_functions import nested_set, add_keys_nested_dict, nested_get

# import asyncio

# Dictionary that is modified / queried as part of tests
Expand All @@ -11,7 +11,6 @@

# @pytest.mark.asyncio
# async def test_nested_set():
@pytest
def test_nested_set():
expected_output = { 1: {'name': 'Breaking Bad 1', 'data': {'episodes': 3, 'year': 1991, 'actors': ['Peter', 'Paul', 'Ppacey']}},
2: {'name': 'Breaking Bad 2', 'data': {'episodes': 6, 'year': 1994, 'actors': ['Weter', 'Waul', 'Wpacey']}},
Expand All @@ -21,7 +20,6 @@ def test_nested_set():
nested_set(output, [2, 'data' ,'year'], 1994)
assert expected_output == output

@pytest
def test_nested_set_conditions():
input = { 1: [{'year': 2001, 'rating': 'high'}, {'year': 2002, 'rating': 'high'}, {'year': 2003, 'rating': 'high'}],
2: [{'year': 2001, 'rating': 'high'}, {'year': 2002, 'rating': 'high'}, {'year': 2003, 'rating': 'high'}]}
Expand All @@ -31,15 +29,13 @@ def test_nested_set_conditions():
nested_set(output, [2, 'rating'], 'LOW', {'year': 2003})
assert expected_output == output

@pytest
def test_nested_set_conditions_multiple():
input = { 1: [{'rating': 'high', 'color': 1, 'stack': 1}, {'rating': 'high', 'color': 2, 'stack': 2}, {'rating': 'high', 'color': 2, 'stack': 1}]}
expected_output = { 1: [{'rating': 'high', 'color': 1, 'stack': 1}, {'rating': 'high', 'color': 2, 'stack': 2}, {'rating': 'LOW', 'color': 2, 'stack': 1}]}
output = input
nested_set(output, [1, 'rating'], 'LOW', {'color': 2, 'stack': 1})
assert expected_output == output

@pytest
def test_add_keys_nested_dict():
expected_output = { 1: {'name': 'Breaking Bad 1', 'data': {'episodes': 3, 'year': 1991, 'actors': ['Peter', 'Paul', 'Ppacey']}},
2: {'name': 'Breaking Bad 2', 'data': {'episodes': 6, 'year': 1994, 'actors': ['Weter', 'Waul', 'Wpacey'], 'spaceship': True}},
Expand All @@ -49,7 +45,6 @@ def test_add_keys_nested_dict():
assert expected_output == output


@pytest
def test_nested_get():
input = { 1: [{'name': 'A', 'color': 1, 'stack': 1}, {'name': 'B', 'color': 2, 'stack': 2}, {'name': 'C', 'color': 2, 'stack': 1}]}
expected_output = ['C']
Expand Down

0 comments on commit 4fdb6ee

Please sign in to comment.