def test_get_radiation_estimated_actuals_404(): """Test get_radiation_estimated_actuals with 404 status code.""" # Arrange api_key = '12345' resource_id = '1234-1234' endpoint = 'weather/estimated_actuals' period = 'PT30M' hours = '170' expected_url = f'{BASE_URL}/{UTILTY_URI}/{resource_id}/{endpoint}' responses.add(responses.GET, expected_url, status=404) # Act site = UtilitySite(api_key, resource_id) with pytest.raises(SiteError): site.get_radiation_estimated_actuals(period, hours)
def test_get_radiation_estimated_actuals_200(): """Test get_radiation_estimated_actuals with 200 status code.""" # Arrange api_key = '12345' resource_id = '1234-1234' endpoint = 'weather/estimated_actuals' period = 'PT30M' hours = '170' expected_url = f'{BASE_URL}/{UTILTY_URI}/{resource_id}/{endpoint}' estimated_actual_response = { "estimated_actuals": [{ "pv_estimate": "10", "period_end": "2018-01-01T01:00:00.00000Z", "period": "PT30M" }, { "pv_estimate": "9", "period_end": "2018-01-01T12:30:00.00000Z", "period": "PT30M" }] } responses.add(responses.GET, expected_url, json=estimated_actual_response, status=200, content_type='applicaiton/json') # Act site = UtilitySite(api_key, resource_id) estimated_actuals = site.get_radiation_estimated_actuals(period, hours) # Assert assert isinstance(estimated_actuals, dict) assert len(estimated_actuals['estimated_actuals']) == 2
def test_get_radiation_estimated_actuals_429(): """Test get_radiation_estimated_actuals with 429 status code.""" # Arrange api_key = '12345' resource_id = '1234-1234' endpoint = 'weather/estimated_actuals' period = 'PT30M' hours = '170' expected_url = f'{BASE_URL}/{UTILTY_URI}/{resource_id}/{endpoint}' headers = {'x-rate-limit-reset': '155555555'} responses.add(responses.GET, expected_url, status=429, adding_headers=headers) # Act site = UtilitySite(api_key, resource_id) with pytest.raises(RateLimitExceeded): site.get_radiation_estimated_actuals(period, hours)