Skip to content

Commit

Permalink
Update test_purpleair_api.py
Browse files Browse the repository at this point in the history
- adding coverage for the getters
  • Loading branch information
carlkidcrypto committed Nov 12, 2023
1 parent 9843c69 commit 59be588
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/test_purpleair_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ def test_purpleairapi_with_two_args(self):
your_api_read_key="123456789", your_ipv4_address=["192.168.1.2"]
)

def test_purpleairapi_getters(self):
"""
Test the PurpleAirAPI getters.
"""

# Setup
fake_url_request = "https://api.purpleair.com/v1/keys"

# Action and Expected Result
with requests_mock.Mocker() as m:
m.get(
fake_url_request,
text='{"api_version" : "1.1.1", "time_stamp": 987654321, "api_key_type": "WRITE"}',
status_code=200,
)

paa = PurpleAirAPI(your_api_write_key="123456789")

self.assertEqual(paa.get_api_key_last_checked["123456789"], 987654321)
self.assertEqual(paa.get_api_key_type["123456789"], "WRITE")
self.assertEqual(paa.get_api_versions["123456789"], "1.1.1")


if __name__ == "__main__":
unittest.main()

0 comments on commit 59be588

Please # to comment.