mirror of
https://github.com/daniviga/bite.git
synced 2024-11-25 14:26:14 +01:00
Compare commits
No commits in common. "0fce565c85a993d19ddd0d4e407614a102c2aa08" and "b1d0f35cf79781bbf00dfc8bcc26bcd14fca59bb" have entirely different histories.
0fce565c85
...
b1d0f35cf7
|
@ -1,19 +0,0 @@
|
||||||
# Generated by Django 3.1 on 2020-08-23 13:40
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import telemetry.models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('telemetry', '0008_auto_20200619_1627'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='telemetry',
|
|
||||||
name='payload',
|
|
||||||
field=models.JSONField(validators=[telemetry.models.telemetry_validation]),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -20,6 +20,7 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
from django.contrib.postgres.fields import JSONField
|
||||||
|
|
||||||
from api.models import Device
|
from api.models import Device
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ class Telemetry(models.Model):
|
||||||
clock = models.IntegerField(
|
clock = models.IntegerField(
|
||||||
validators=[MinValueValidator(0)],
|
validators=[MinValueValidator(0)],
|
||||||
null=True)
|
null=True)
|
||||||
payload = models.JSONField(validators=[telemetry_validation])
|
payload = JSONField(validators=[telemetry_validation])
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['-time', 'device']
|
ordering = ['-time', 'device']
|
||||||
|
|
|
@ -26,12 +26,12 @@ class ApiTestCase(TestCase):
|
||||||
c = Client()
|
c = Client()
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"id": "sensor.server.domain",
|
'id': 'sensor.server.domain',
|
||||||
"light": 434,
|
'light': 434,
|
||||||
"temperature": {
|
'temperature': {
|
||||||
"celsius": 27.02149,
|
'celsius': 27.02149,
|
||||||
"raw": 239,
|
'raw': 239,
|
||||||
"volts": 0.770215
|
'volts': 0.770215
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,4 +69,4 @@ class ApiTestCase(TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response.json()['transport'], 'http')
|
response.json()['transport'], 'http')
|
||||||
self.assertJSONEqual(
|
self.assertJSONEqual(
|
||||||
response.json()['payload'], self.payload)
|
json.dumps(response.json()['payload']), self.payload)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user