def test_game_list_presence(self): """A list of games is displayed on the index page.""" create_game('Super Street Fighter II Turbo', '') create_game('Mortal Kombat X', '') response = self.client.get(reverse('mentor:index')) self.assertEqual(response.status_code, 200) self.assertContains(response, 'Super Street Fighter II Turbo') self.assertContains(response, 'Mortal Kombat X')
def test_img_url(self): """Returns base url for character, with character name snakified.""" game = create_game('Super Smash Bros. Ultimate', 'Smash Ultimate') char = Character.objects.create(name='Rosalina & Luma', game=game) self.assertEqual( char.img_url(), 'games/smash_ultimate/characters/rosalina_&_luma.png')
def test_rel_img_url(self): """Returns relative url for character, with character name snakified.""" game = create_game('Super Smash Bros. Ultimate', 'Smash Ultimate') char = Character.objects.create(name='Pac-Man', game=game) rel_url = char.rel_img_url() self.assertEqual( rel_url, 'mentor/images/games/smash_ultimate/characters/pac-man.png')
def test_img_url_with_punctuation(self): """Returns correctly formatted url, with the game title being snakified.""" game = create_game('Super Smash Bros.: Hero\'s Bla$%de & M(*ight!', '') url = game.img_url() self.assertEqual( url, 'mentor/images/games/super_smash_bros_heros_blade_&_might/game_cover.png' )
def test_tools_page(self): """A game can be selected from index page, and the user is navigated to the tools page for that game.""" s = self.selenium game = create_game('Mortal Kombat X') s.get(self.live_server_url) game_anchor = s.find_element_by_link_text(str(game)).click() assert 'Mortal Kombat X: Tools' in s.page_source assert 'Insights' in s.page_source
def test_logout(self): """The user is logged out once the logout link is selected in the navbar.""" s = self.selenium user = create_user('DeterminedDemetrius', password="******") game = create_game('Super Smash Bros. Melee', 'Melee') login(s, self.live_server_url, user.username, "I'llNeverRememberThisOne") s.find_element_by_id('logout').click() assert 'Log out' not in s.page_source assert 'Select a game:' in s.page_source # Attempt to go to character overlay, which you can only access whilst logged in: s.get(self.live_server_url + reverse('mentor:char_overlay', args=[game.id])) assert 'login' in s.current_url
def test_img_url_with_title(self): """Returns correctly formatted url using game's title when no short_title exists""" game = create_game('Super Smash Bros Melee', '') url = game.img_url() self.assertEqual( url, 'mentor/images/games/super_smash_bros_melee/game_cover.png')
def test_img_url_with_short_title(self): """Returns correctly formatted url using game's short_title when it exists.""" game = create_game('Super Smash Bros. for Wii U', 'Smash 4') url = game.img_url() self.assertEqual(url, 'mentor/images/games/smash_4/game_cover.png')
def test__str__with_no_short_title(self): """Returns title if no short_title exists (empty string).""" game = create_game('Super Street Fighter II Turbo', '') self.assertEqual(str(game), game.title)
def test__str__with_existing_short_title(self): """Returns short title when one exists.""" game = create_game('Super Smash Bros. Brawl', 'Brawl') self.assertEqual(str(game), game.short_title)
def setUp(self): super(InsightsTests, self).setUp() self.game = create_game('Super Smash Bros. Ultimate', 'Smash Ultimate')
def setUp(self): super(CharOverlayTests, self).setUp() self.game = create_game('Super Smash Bros. Ultimate', 'Smash Ultimate') self.user = create_user('Clive', password='******')