Skip to content

Commit

Permalink
test: Add test for web result view with author names
Browse files Browse the repository at this point in the history
  • Loading branch information
mhthies committed Jul 12, 2020
1 parent a00a85d commit 3bda7d4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ def setUp(self) -> None:
def tearDown(self) -> None:
cherrypy.engine.exit()

def _simple_sample_game(self) -> List[game.TranslatedMessage]:
def _simple_sample_game(self, with_authors: bool = False) -> List[game.TranslatedMessage]:
self.game_server.new_game(21, "Funny Group")
self.game_server.set_show_result_names(21, with_authors)
self.game_server.join_game(21, 1)
self.game_server.join_game(21, 2)
self.game_server.join_game(21, 3)
Expand Down Expand Up @@ -77,3 +78,16 @@ def test_simple_result(self) -> None:
resp = resp.click(href=re.compile(r'/sheet/'), index=0)
self.assertEqual(200, resp.status_int)
self.assertRegex(resp.text, r".*Question [1-3].*")

def test_result_with_authors(self) -> None:
finalize_messages = self._simple_sample_game(with_authors=True)
result_path = self._find_result_url(finalize_messages, 21)
self.assertIsNotNone(result_path)

resp = self.app.get(result_path)
self.assertEqual(200, resp.status_int)
resp.mustcontain("Question 1")
resp.mustcontain("Michael")
resp = resp.click(href=re.compile(r'/game/(?!.*authors=1)'), index=0)
resp.mustcontain("Question 1")
resp.mustcontain(no=["Michael"])

0 comments on commit 3bda7d4

Please sign in to comment.