Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
Alter SensorDataValue Field "value" (#11)
Browse files Browse the repository at this point in the history
* alter value field from textfield to decimalfield

* updae test to test against decimal value

* update migration files
  • Loading branch information
karimkawambwa authored Jan 22, 2019
1 parent f7a2342 commit 41f8d39
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
20 changes: 20 additions & 0 deletions feinstaub/sensors/migrations/0021_auto_20190122_0917.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-01-22 09:17
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sensors', '0020_auto_20190122_0600'),
]

operations = [
migrations.AlterField(
model_name='sensordatavalue',
name='value',
field=models.DecimalField(blank=True, decimal_places=11, max_digits=14, null=True),
),
]
2 changes: 1 addition & 1 deletion feinstaub/sensors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __str__(self):
class SensorDataValue(TimeStampedModel):

sensordata = models.ForeignKey(SensorData, related_name='sensordatavalues')
value = models.TextField(db_index=True)
value = models.DecimalField(max_digits=14, decimal_places=11, null=True, blank=True)
value_type = models.CharField(max_length=100, choices=SENSOR_TYPE_CHOICES,
db_index=True)

Expand Down
4 changes: 2 additions & 2 deletions feinstaub/tests/test_full_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def test_full_data_push(self, sensor, data_fixture):

assert sd.sensordatavalues.count() == 2
assert sd.sensordatavalues.get(value_type="P1").value ==\
str(data_fixture['sensordatavalues'][0]['value'])
data_fixture['sensordatavalues'][0]['value']
assert sd.sensordatavalues.get(value_type="P2").value ==\
str(data_fixture['sensordatavalues'][1]['value'])
data_fixture['sensordatavalues'][1]['value']

assert sd.location == sensor.node.location

Expand Down

0 comments on commit 41f8d39

Please sign in to comment.