-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started getting an endpoint test going
- Loading branch information
Showing
4 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import pytest | ||
from rest_framework.test import APIClient | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
return APIClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
# TODO: | ||
# - Schema with data fields | ||
# - Submit data to the endpoints | ||
import pytest | ||
from django.urls import reverse | ||
from rest_framework import status | ||
|
||
from shedpi_hub_dashboard.tests.utils.factories import DeviceModuleFactory | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_device_reading_submission(client): | ||
schema = { | ||
"$id": "https://example.com/person.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "Person", | ||
"type": "object", | ||
"properties": { | ||
"temperature": {"type": "string", "description": "The Temperature"}, | ||
}, | ||
} | ||
device_module = DeviceModuleFactory(schema=schema) | ||
# devicemodulereading-list | ||
# devicemodulereading-detail | ||
url = reverse("devicemodulereading-detail", kwargs={"pk": device_module.id}) | ||
|
||
response = client.post(url, data={"device_module_id": device_module.id}) | ||
|
||
assert response.status_code == status.HTTP_200_OK | ||
assert set(response.data.keys()) == {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters