mirror of
https://github.com/LukeHagar/pokemonAPI-Amari.git
synced 2025-12-06 04:20:57 +00:00
Updated Readme for correctness of interactive_test name.
Adding IDE Project files Created an interactive_test_poke_api.py file that takes user input as an example.
This commit is contained in:
15
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
15
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,15 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ourVersions">
|
||||
<value>
|
||||
<list size="2">
|
||||
<item index="0" class="java.lang.String" itemvalue="3.13" />
|
||||
<item index="1" class="java.lang.String" itemvalue="3.12" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.12 (pokemonAPI-Amari)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pokemonAPI-Amari)" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/pokemonAPI-Amari.iml" filepath="$PROJECT_DIR$/.idea/pokemonAPI-Amari.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/pokemonAPI-Amari.iml
generated
Normal file
14
.idea/pokemonAPI-Amari.iml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -63,7 +63,7 @@ This will demonstrate how to fetch Pokémon and generation data using the SDK.
|
||||
To run the interactive test that allows you to input a generation ID and output Pokémon in that generation, execute:
|
||||
|
||||
```bash
|
||||
python tests/interactive_test_generation_pokemon.py
|
||||
python tests/interactive_test_poke_api.py
|
||||
```
|
||||
|
||||
When prompted, enter a generation ID (e.g., "1") to see the Pokémon in that generation.
|
||||
|
||||
54
tests/interactive_test_poke_api.py
Normal file
54
tests/interactive_test_poke_api.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import unittest
|
||||
from poke_sdk.PokeAPI import PokeAPI
|
||||
from poke_sdk.exceptions import APIError
|
||||
|
||||
|
||||
class InteractiveTestPokeAPI(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Set up the API client for testing."""
|
||||
cls.api = PokeAPI()
|
||||
|
||||
def test_get_pokemon_with_user_input(self):
|
||||
"""Test retrieving a Pokémon based on user input. Will return Pokémon Type and generation"""
|
||||
pokemon_name = input("Enter the Pokémon name (e.g., pikachu, charizard, blastoise): ")
|
||||
try:
|
||||
response = self.api.get_pokemon(pokemon_name)
|
||||
print(f"Retrieved Pokémon: {response.name}, ID: {response.id}, Types: {response.types}")
|
||||
self.assertEqual(response.name, pokemon_name)
|
||||
except APIError as e:
|
||||
self.fail(f"APIError occurred: {e}")
|
||||
except Exception as e:
|
||||
print(f"An unexpected error occurred: {e}")
|
||||
|
||||
def test_get_pokemon_in_generation(self):
|
||||
"""Test retrieving Pokémon in a specified generation based on user input. Returns all Pokémon in generation"""
|
||||
generation_id = input("Enter the generation ID (e.g., 1): ")
|
||||
try:
|
||||
response = self.api.get_generation(generation_id)
|
||||
print(f"Retrieved Generation: {response.name}, ID: {response.id}")
|
||||
print("Pokémon in this generation:")
|
||||
for pokemon in response.pokemon_species:
|
||||
print(f"- {pokemon}")
|
||||
except APIError as e:
|
||||
self.fail(f"APIError occurred: {e}")
|
||||
except Exception as e:
|
||||
print(f"An unexpected error occurred: {e}")
|
||||
|
||||
#Test generation is a valid Pokémon Generation based on user input
|
||||
def test_get_generation_with_user_input(self):
|
||||
"""Test retrieving a generation based on user input. Will validate Pokémon generation is a valid Gen"""
|
||||
generation_id = input("Enter the generation ID, will validate if gen is available(e.g., 1): ")
|
||||
try:
|
||||
response = self.api.get_generation(generation_id)
|
||||
print(f"Retrieved Generation: {response.name}, ID: {response.id}")
|
||||
self.assertEqual(response.id, int(generation_id))
|
||||
except APIError as e:
|
||||
self.fail(f"APIError occurred: {e}")
|
||||
except Exception as e:
|
||||
print(f"An unexpected error occurred: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user