Skip to content

Commit

Permalink
test: add api test
Browse files Browse the repository at this point in the history
  • Loading branch information
dleard committed Sep 17, 2024
1 parent 2c2b826 commit c598149
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bc_obps/reporting/tests/api/test_fuel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.test import Client
import pytest

pytestmark = pytest.mark.django_db
client = Client()
pytest.endpoint = "/api/reporting/fuel"


class TestActivityData:
def test_invalid_without_fuel_name(self):
response = client.get(f'{pytest.endpoint}')
assert response.status_code == 422

def test_invalid_fuel(self):
response = client.get(f'{pytest.endpoint}?fuel_name=non-existent')
assert response.status_code == 404

def test_returns_fuel_data(self):
response = client.get('/api/reporting/fuel?fuel_name=Acetylene')
print(response.json())
assert response.status_code == 200
assert response.json().get('name') == 'Acetylene'
assert response.json().get('classification') == 'Exempted Non-biomass'
assert response.json().get('unit') == 'Sm^3'

0 comments on commit c598149

Please sign in to comment.