vancauwe commited on
Commit
8963e74
·
1 Parent(s): 7b28238

fix: adapt tests to refactor and explicit module names

Browse files
src/apptest/demo_whale_viewer.py CHANGED
@@ -17,14 +17,14 @@ src_dir = path.dirname( path.dirname( path.abspath(__file__) ) )
17
  sys.path.append(src_dir)
18
 
19
 
20
- import whale_viewer as sw_wv
21
 
22
  # a menu to pick one of the images
23
  title = st.title("Whale Viewer testing")
24
- species = st.selectbox("Species", sw_wv.WHALE_CLASSES)
25
 
26
  if species is not None:
27
  # and display the image + reference
28
  st.write(f"Selected species: {species}")
29
- sw_wv.display_whale([species], 0, st)
30
 
 
17
  sys.path.append(src_dir)
18
 
19
 
20
+ import whale_viewer as whale_viewer
21
 
22
  # a menu to pick one of the images
23
  title = st.title("Whale Viewer testing")
24
+ species = st.selectbox("Species", whale_viewer.WHALE_CLASSES)
25
 
26
  if species is not None:
27
  # and display the image + reference
28
  st.write(f"Selected species: {species}")
29
+ whale_viewer.display_whale([species], 0, st)
30
 
tests/test_demo_whale_viewer.py CHANGED
@@ -1,7 +1,7 @@
1
  from streamlit.testing.v1 import AppTest
2
  import pytest # for the exception testing
3
 
4
- import whale_viewer as sw_wv # for data
5
 
6
 
7
  def test_selectbox_ok():
@@ -45,10 +45,10 @@ def test_selectbox_ok():
45
  print("PROPS=> ", dir(at.selectbox[0])) # no length unfortunately,
46
  # test it dynamically intead.
47
  # should be fine
48
- at.selectbox[0].select_index(len(sw_wv.WHALE_CLASSES)-1).run()
49
  # should fail
50
  with pytest.raises(Exception):
51
- at.selectbox[0].select_index(len(sw_wv.WHALE_CLASSES)).run()
52
 
53
  def test_img_props():
54
  '''
@@ -95,15 +95,15 @@ def test_img_props():
95
  # we're expecting the caption to be WHALE_REFERENCES[ix]
96
  print(parsed_proto)
97
  assert "caption" in parsed_proto
98
- assert parsed_proto["caption"] == sw_wv.WHALE_REFERENCES[ix]
99
  assert "url" in parsed_proto
100
  assert parsed_proto["url"].startswith("/mock/media")
101
 
102
- print(sw_wv.WHALE_REFERENCES[ix])
103
 
104
  # now let's switch to another index
105
  ix = 15
106
- v15 = sw_wv.WHALE_CLASSES[ix]
107
  v15_str = v15.replace("_", " ").title()
108
  at.selectbox[0].set_value(v15).run()
109
 
@@ -118,7 +118,7 @@ def test_img_props():
118
  # we're expecting the caption to be WHALE_REFERENCES[ix]
119
  print(parsed_proto)
120
  assert "caption" in parsed_proto
121
- assert parsed_proto["caption"] == sw_wv.WHALE_REFERENCES[ix]
122
  assert "url" in parsed_proto
123
  assert parsed_proto["url"].startswith("/mock/media")
124
 
 
1
  from streamlit.testing.v1 import AppTest
2
  import pytest # for the exception testing
3
 
4
+ import whale_viewer as whale_viewer # for data
5
 
6
 
7
  def test_selectbox_ok():
 
45
  print("PROPS=> ", dir(at.selectbox[0])) # no length unfortunately,
46
  # test it dynamically intead.
47
  # should be fine
48
+ at.selectbox[0].select_index(len(whale_viewer.WHALE_CLASSES)-1).run()
49
  # should fail
50
  with pytest.raises(Exception):
51
+ at.selectbox[0].select_index(len(whale_viewer.WHALE_CLASSES)).run()
52
 
53
  def test_img_props():
54
  '''
 
95
  # we're expecting the caption to be WHALE_REFERENCES[ix]
96
  print(parsed_proto)
97
  assert "caption" in parsed_proto
98
+ assert parsed_proto["caption"] == whale_viewer.WHALE_REFERENCES[ix]
99
  assert "url" in parsed_proto
100
  assert parsed_proto["url"].startswith("/mock/media")
101
 
102
+ print(whale_viewer.WHALE_REFERENCES[ix])
103
 
104
  # now let's switch to another index
105
  ix = 15
106
+ v15 = whale_viewer.WHALE_CLASSES[ix]
107
  v15_str = v15.replace("_", " ").title()
108
  at.selectbox[0].set_value(v15).run()
109
 
 
118
  # we're expecting the caption to be WHALE_REFERENCES[ix]
119
  print(parsed_proto)
120
  assert "caption" in parsed_proto
121
+ assert parsed_proto["caption"] == whale_viewer.WHALE_REFERENCES[ix]
122
  assert "url" in parsed_proto
123
  assert parsed_proto["url"].startswith("/mock/media")
124
 
tests/test_input_handling.py CHANGED
@@ -1,7 +1,7 @@
1
  import pytest
2
  from pathlib import Path
3
 
4
- from input_handling import is_valid_email, is_valid_number
5
  from input.input_validator import get_image_latlon, decimal_coords, get_image_datetime
6
 
7
  # generate tests for is_valid_email
 
1
  import pytest
2
  from pathlib import Path
3
 
4
+ from input.input_validator import is_valid_email, is_valid_number
5
  from input.input_validator import get_image_latlon, decimal_coords, get_image_datetime
6
 
7
  # generate tests for is_valid_email