Skip to content

Commit

Permalink
fixed 'possible_values' field of characteristic endpoint
Browse files Browse the repository at this point in the history
loop that adds values to 'possible_values' used wrong value in conditional. Created test to verify behavior is as expected.
  • Loading branch information
fissionprime committed Jul 6, 2021
1 parent 0ec78d6 commit 1ae3964
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ node_modules
.vscode
*.env
Resources/nginx/ssl/*
!Resources/nginx/ssl/*.sample.*
!Resources/nginx/ssl/*.sample.*
.idea*
2 changes: 1 addition & 1 deletion pokemon_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def get_values(self, obj):

mod = obj.gene_mod_5
values = []
while mod <= 30:
while mod <= 31:
values.append(mod)
mod += 5

Expand Down
15 changes: 15 additions & 0 deletions pokemon_v2/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4337,6 +4337,21 @@ def test_characteristic_api(self):
"{}{}/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):

Expand Down

0 comments on commit 1ae3964

Please sign in to comment.