mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-24 20:33:04 +00:00
fixed 'possible_values' field of characteristic endpoint
loop that adds values to 'possible_values' used wrong value in conditional. Created test to verify behavior is as expected.
This commit is contained in:
parent
0ec78d6d0d
commit
1ae3964a5f
3 changed files with 18 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -9,4 +9,5 @@ node_modules
|
|||
.vscode
|
||||
*.env
|
||||
Resources/nginx/ssl/*
|
||||
!Resources/nginx/ssl/*.sample.*
|
||||
!Resources/nginx/ssl/*.sample.*
|
||||
.idea*
|
|
@ -487,7 +487,7 @@ class CharacteristicDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
mod = obj.gene_mod_5
|
||||
values = []
|
||||
while mod <= 30:
|
||||
while mod <= 31:
|
||||
values.append(mod)
|
||||
mod += 5
|
||||
|
||||
|
|
|
@ -4337,6 +4337,21 @@ class APITests(APIData, APITestCase):
|
|||
"{}{}/stat/{}/".format(TEST_HOST, API_V2, characteristic.stat.pk),
|
||||
)
|
||||
|
||||
def test_characteristic_values(self):
|
||||
l = []
|
||||
# check for all 5 possible values of gene_modulo
|
||||
for modulo in range(5):
|
||||
characteristic = self.setup_characteristic_data(gene_mod_5=modulo)
|
||||
# note that 'possible_values' is computed solely from gene_modulo
|
||||
# thus it is fine that our test characteristics are indexed 1-5
|
||||
result = self.client.get(
|
||||
"{}/characteristic/{}/".format(API_V2, characteristic.pk))
|
||||
for i in range(len(result.data['possible_values'])):
|
||||
self.assertEqual(
|
||||
result.data['possible_values'][i], characteristic.gene_mod_5 + i * 5
|
||||
)
|
||||
|
||||
|
||||
# Nature Tests
|
||||
def test_nature_api(self):
|
||||
|
||||
|
|
Loading…
Reference in a new issue