Skip to content

Commit

Permalink
fix: adapt tests to refactor and explicit module names
Browse files Browse the repository at this point in the history
  • Loading branch information
vancauwe committed Jan 25, 2025
1 parent 7b28238 commit 8963e74
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/apptest/demo_whale_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
sys.path.append(src_dir)


import whale_viewer as sw_wv
import whale_viewer as whale_viewer

# a menu to pick one of the images
title = st.title("Whale Viewer testing")
species = st.selectbox("Species", sw_wv.WHALE_CLASSES)
species = st.selectbox("Species", whale_viewer.WHALE_CLASSES)

if species is not None:
# and display the image + reference
st.write(f"Selected species: {species}")
sw_wv.display_whale([species], 0, st)
whale_viewer.display_whale([species], 0, st)

14 changes: 7 additions & 7 deletions tests/test_demo_whale_viewer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from streamlit.testing.v1 import AppTest
import pytest # for the exception testing

import whale_viewer as sw_wv # for data
import whale_viewer as whale_viewer # for data


def test_selectbox_ok():
Expand Down Expand Up @@ -45,10 +45,10 @@ def test_selectbox_ok():
print("PROPS=> ", dir(at.selectbox[0])) # no length unfortunately,
# test it dynamically intead.
# should be fine
at.selectbox[0].select_index(len(sw_wv.WHALE_CLASSES)-1).run()
at.selectbox[0].select_index(len(whale_viewer.WHALE_CLASSES)-1).run()
# should fail
with pytest.raises(Exception):
at.selectbox[0].select_index(len(sw_wv.WHALE_CLASSES)).run()
at.selectbox[0].select_index(len(whale_viewer.WHALE_CLASSES)).run()

def test_img_props():
'''
Expand Down Expand Up @@ -95,15 +95,15 @@ def parse_proto(proto_str):
# we're expecting the caption to be WHALE_REFERENCES[ix]
print(parsed_proto)
assert "caption" in parsed_proto
assert parsed_proto["caption"] == sw_wv.WHALE_REFERENCES[ix]
assert parsed_proto["caption"] == whale_viewer.WHALE_REFERENCES[ix]
assert "url" in parsed_proto
assert parsed_proto["url"].startswith("/mock/media")

print(sw_wv.WHALE_REFERENCES[ix])
print(whale_viewer.WHALE_REFERENCES[ix])

# now let's switch to another index
ix = 15
v15 = sw_wv.WHALE_CLASSES[ix]
v15 = whale_viewer.WHALE_CLASSES[ix]
v15_str = v15.replace("_", " ").title()
at.selectbox[0].set_value(v15).run()

Expand All @@ -118,7 +118,7 @@ def parse_proto(proto_str):
# we're expecting the caption to be WHALE_REFERENCES[ix]
print(parsed_proto)
assert "caption" in parsed_proto
assert parsed_proto["caption"] == sw_wv.WHALE_REFERENCES[ix]
assert parsed_proto["caption"] == whale_viewer.WHALE_REFERENCES[ix]
assert "url" in parsed_proto
assert parsed_proto["url"].startswith("/mock/media")

Expand Down
2 changes: 1 addition & 1 deletion tests/test_input_handling.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pathlib import Path

from input_handling import is_valid_email, is_valid_number
from input.input_validator import is_valid_email, is_valid_number
from input.input_validator import get_image_latlon, decimal_coords, get_image_datetime

# generate tests for is_valid_email
Expand Down

0 comments on commit 8963e74

Please sign in to comment.