Skip to content

Commit

Permalink
tweak appinfo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
briehl committed Jun 11, 2024
1 parent c070096 commit 71a78f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/NarrativeService/apps/appinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from installed_clients.CatalogClient import Catalog
from installed_clients.NarrativeMethodStoreClient import NarrativeMethodStore

IGNORE_CATEGORIES = {"inactive", "importers", "viewers"}
APP_TAGS = {"release", "beta", "dev"}
IGNORE_CATEGORIES: set = {"inactive", "importers", "viewers"}
APP_TAGS: set = {"release", "beta", "dev"}


def get_ignore_categories() -> dict[str, int]:
Expand Down
9 changes: 4 additions & 5 deletions test/integration/test_appinfo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import pytest
from installed_clients.CatalogClient import Catalog
from installed_clients.NarrativeMethodStoreClient import NarrativeMethodStore
from NarrativeService.apps.appinfo import get_all_app_info
from NarrativeService.apps.appinfo import IGNORE_CATEGORIES, get_all_app_info
from NarrativeService.NarrativeServiceImpl import NarrativeService

IGNORE_CATEGORIES = {"inactive", "importers", "viewers"}
APP_TAGS = ["release", "beta", "dev"]
USER_ID = "wjriehl"

Expand Down Expand Up @@ -36,6 +35,7 @@ def validate_app_info(info):
app = info["app_infos"][a]["info"]
for str_key in app_str_keys:
assert str_key in app
assert isinstance(app[str_key], str)
for list_key in app_list_keys:
assert list_key in app
assert isinstance(app[list_key], list)
Expand All @@ -61,7 +61,7 @@ def test_get_all_app_info_unit_ok(
validate_app_info(info)


@pytest.mark.parametrize("bad_tag", [None, [], {}, "foo", 5, -3])
@pytest.mark.parametrize("bad_tag", [None, [], {}, "foo", 5, -3, True, ""])
def test_get_all_app_info_bad_tag(
bad_tag: str,
nms_client: NarrativeMethodStore,
Expand Down Expand Up @@ -104,5 +104,4 @@ def test_get_ignore_categories_ok(
service_impl: NarrativeMethodStore
) -> None:
ignore_categories = service_impl.get_ignore_categories(context)[0]
expected_keys = {"inactive", "importers", "viewers"}
assert expected_keys == set(ignore_categories.keys())
assert set(ignore_categories.keys()) == IGNORE_CATEGORIES
8 changes: 3 additions & 5 deletions test/unit/test_appinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import pytest
from installed_clients.CatalogClient import Catalog
from installed_clients.NarrativeMethodStoreClient import NarrativeMethodStore
from NarrativeService.apps.appinfo import get_all_app_info, get_ignore_categories
from NarrativeService.apps.appinfo import IGNORE_CATEGORIES, get_all_app_info, get_ignore_categories

IGNORE_CATEGORIES = {"inactive", "importers", "viewers"}
APP_TAGS = ["release", "beta", "dev"]
USER_ID = "some_user"
NUM_DATA_APPS = 3
Expand Down Expand Up @@ -41,7 +40,7 @@ def test_get_all_app_info_ok(
assert info["app_infos"][FAVORITE]["favorite"] == FAV_TIME


@pytest.mark.parametrize("bad_tag", [None, [], {}, "foo", 5, -3])
@pytest.mark.parametrize("bad_tag", [None, [], {}, "foo", 5, -3, True, ""])
def test_get_all_app_info_bad_tag(
bad_tag: str,
mock_nms: NarrativeMethodStore,
Expand All @@ -53,5 +52,4 @@ def test_get_all_app_info_bad_tag(

def test_get_ignore_categories_ok() -> None:
ignore_categories = get_ignore_categories()
expected = {"inactive", "importers", "viewers"}
assert expected == set(ignore_categories.keys())
assert set(ignore_categories.keys()) == IGNORE_CATEGORIES

0 comments on commit 71a78f6

Please sign in to comment.