Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Using mock testing to test the new API calling function.
  • Loading branch information
am1520x committed Oct 30, 2024
1 parent 4cce632 commit 8ee35d1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test_iss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
import requests
from unittest.mock import patch
from times import iss_passes

# Sample mock response data
mock_response_data = {
"passes": [
{"startUTC": 1609459200, "endUTC": 1609459800},
{"startUTC": 1609462800, "endUTC": 1609463400}
]
}

@patch('times.requests.get')
def test_iss_passes(mock_get):
# Configure the mock to return a response with our mock data
mock_get.return_value.json.return_value = mock_response_data

api_key = "test_api_key"
lat = 56
lon = 0
result = iss_passes(api_key, lat, lon)

expected = [
("2021-01-01 00:00:00", "2021-01-01 00:10:00"),
("2021-01-01 01:00:00", "2021-01-01 01:10:00")
]

assert result == expected

0 comments on commit 8ee35d1

Please sign in to comment.