Using PEP 0008 as Guide

Attempting to incorporate the style guide linked by phalt.  Should have
no functional changes, but is hopefully easier to read/review.
This commit is contained in:
SiMylo 2016-02-08 08:28:55 -06:00
parent b08392cd3e
commit cba1cbe292

View file

@ -3530,13 +3530,20 @@ class APITests(APIData, APITestCase):
pokemon_type = self.setup_pokemon_type_data(pokemon=pokemon)
pokemon_item = self.setup_pokemon_item_data(pokemon=pokemon)
pokemon_game_index = self.setup_pokemon_game_index_data(pokemon=pokemon, game_index=10)
# To test issue #85, we will create one move that has multiple learn levels in different
# version groups. Later, we'll assert that we only got one move record back.
# To test issue #85, we will create one move that has multiple
# learn levels in different version groups. Later, we'll
# assert that we only got one move record back.
pokemon_move = self.setup_move_data(name='mv for pkmn')
pokemon_moves = []
for move in range(0,4):
version_group = self.setup_version_group_data(name='ver grp '+str(move)+' for pkmn')
pokemon_moves.append(self.setup_pokemon_move_data(pokemon=pokemon,move=pokemon_move,version_group=version_group,level=move))
version_group = self.setup_version_group_data(
name='ver grp '+str(move)+' for pkmn')
new_move = self.setup_pokemon_move_data(
pokemon=pokemon,
move=pokemon_move,
version_group=version_group,
level=move)
pokemon_moves.append(new_move)
encounter_method = self.setup_encounter_method_data(name='encntr mthd for lctn area')
location_area1 = self.setup_location_area_data(name='lctn1 area for base pkmn')
@ -3580,21 +3587,56 @@ class APITests(APIData, APITestCase):
self.assertEqual(response.data['held_items'][0]['version_details'][0]['rarity'], pokemon_item.rarity)
self.assertEqual(response.data['held_items'][0]['version_details'][0]['version']['name'], pokemon_item.version.name)
self.assertEqual(response.data['held_items'][0]['version_details'][0]['version']['url'], '{}{}/version/{}/'.format(test_host, api_v2, pokemon_item.version.pk))
# move params
# Make sure that we only got one move back, but that we got all of the distinct version group
# and learn level values. (See issue #85)
self.assertEqual(len(response.data['moves']),1)
self.assertEqual(response.data['moves'][0]['move']['name'], pokemon_moves[0].move.name)
self.assertEqual(response.data['moves'][0]['move']['url'], '{}{}/move/{}/'.format(test_host, api_v2, pokemon_moves[0].move.pk))
self.assertEqual(len(response.data['moves'][0]['version_group_details']),len(pokemon_moves));
for version_group in range(0,len(pokemon_moves)):
expected = pokemon_move[version_group]
actual = response.data['moves'][0]['version_group_details'][version_group]
self.assertEqual(actual['level_learned_at'], expected.level)
self.assertEqual(actual['version_group']['name'], expected.version_group.name)
self.assertEqual(actual['version_group']['url'], '{}{}/version-group/{}/'.format(test_host, api_v2, expected.version_group.pk))
self.assertEqual(actual['move_learn_method']['name'], expected.move_learn_method.name)
self.assertEqual(actual['move_learn_method']['url'], '{}{}/move-learn-method/{}/'.format(test_host, api_v2, expected.move_learn_method.pk))
# move params -- Make sure that we only got one move back,
# but that we got all of the distinct version group and learn
# level values. (See issue #85)
# Number of Moves
expected = 1
actual = len(response.data['moves'])
self.assertEqual(expected, actual)
# Move name
expected = pokemon_moves[0].move.name
actual = response.data['moves'][0]['move']['name']
self.assertEqual(expected, actual)
# Move URL
expected = '{}{}/move/{}/'.format(
test_host,
api_v2,
pokemon_moves[0].move.pk)
actual = response.data['moves'][0]['move']['url']
self.assertEqual(expected, actual)
# Numbver of version groups
expected = len(pokemon_moves)
actual = len(response.data['moves'][0]['version_group_details'])
self.assertEqual(expected, actual)
for i in range(0,len(pokemon_moves)):
version = response.data['moves'][0]['version_group_details'][i]
# Learn Level
expected = pokemon_moves[i].level
actual = version['level_learned_at']
self.assertEqual(expected ,actual)
# Version Group Name
expected = pokemon_moves[i].version_group.name
actual = version['version_group']['name']
self.assertEqual(expected, actual)
# Version Group URL
expected = '{}{}/version-group/{}/'.format(
test_host,
api_v2,
pokemon_moves[i].version_group.pk)
actual = version['version_group']['url']
self.assertEqual(expected, actual)
# Learn Method Name
expected = pokemon_moves[i].move_learn_method.name
actual = version['move_learn_method']['name']
self.assertEqual(expected, actual)
# Learn Method URL
expected = '{}{}/move-learn-method/{}/'.format(
test_host,
api_v2,
pokemon_moves[i].move_learn_method.pk)
actual = version['move_learn_method']['url']
self.assertEqual(expected, actual)
# game indices params
self.assertEqual(response.data['game_indices'][0]['game_index'], pokemon_game_index.game_index)
self.assertEqual(response.data['game_indices'][0]['version']['name'], pokemon_game_index.version.name)