mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 06:04:18 +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
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@ node_modules
|
||||||
*.env
|
*.env
|
||||||
Resources/nginx/ssl/*
|
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
|
mod = obj.gene_mod_5
|
||||||
values = []
|
values = []
|
||||||
while mod <= 30:
|
while mod <= 31:
|
||||||
values.append(mod)
|
values.append(mod)
|
||||||
mod += 5
|
mod += 5
|
||||||
|
|
||||||
|
|
|
@ -4337,6 +4337,21 @@ class APITests(APIData, APITestCase):
|
||||||
"{}{}/stat/{}/".format(TEST_HOST, API_V2, characteristic.stat.pk),
|
"{}{}/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
|
# Nature Tests
|
||||||
def test_nature_api(self):
|
def test_nature_api(self):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue