adapt a lot of things for django
This commit is contained in:
parent
58e4818b1a
commit
a9bced323b
5
Makefile
5
Makefile
|
@ -6,13 +6,12 @@ run: venv
|
|||
python3 sensors
|
||||
|
||||
test: venv/development
|
||||
pytest --cov=. --cov-report=term
|
||||
pytest --cov=. --cov-report=term sensors/
|
||||
|
||||
venv/development:
|
||||
test -d venv || python3 -m venv venv
|
||||
( \
|
||||
source venv/bin/activate; \
|
||||
pip3 install -e .; \
|
||||
pip3 install -r requirements/development.txt; \
|
||||
)
|
||||
touch venv/development
|
||||
|
@ -21,7 +20,7 @@ venv:
|
|||
test -d venv || python3 -m venv venv
|
||||
( \
|
||||
source venv/bin/activate; \
|
||||
pip3 install .; \
|
||||
pip3 install -r requirements/base.txt; \
|
||||
)
|
||||
|
||||
venv/bin/activate: venv
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-django
|
||||
pep8
|
||||
rope
|
||||
pylint
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Time(models.Model):
|
||||
value = DateTimeField()
|
||||
value = models.DateTimeField()
|
||||
|
||||
|
||||
class Temperatur(models.Model):
|
||||
time = ForeignKeyField(Time, backref='temperatures')
|
||||
value = FloatField()
|
||||
time = models.ForeignKey(Time, on_delete=models.CASCADE)
|
||||
value = models.FloatField()
|
||||
|
||||
|
||||
class Humidity(models.Model):
|
||||
time = ForeignKeyField(Time, backref='humidities')
|
||||
value = FloatField()
|
||||
time = models.ForeignKey(Time, on_delete=models.CASCADE)
|
||||
value = models.FloatField()
|
||||
|
||||
|
||||
class Pressure(models.Model):
|
||||
time = ForeignKeyField(Time, backref='pressures')
|
||||
value = FloatField()
|
||||
time = models.ForeignKey(Time, on_delete=models.CASCADE)
|
||||
value = models.FloatField()
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
import pytest
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
||||
pytestmark=pytest.mark.django_db
|
||||
|
||||
|
||||
def test_create_temperatur():
|
||||
time = models.Time.create(value=datetime.datetime.now)
|
||||
temp = models.Temperatur.create(value=20.0, time=time)
|
||||
assert False
|
||||
|
|
|
@ -29,6 +29,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'collector.apps.CollectorConfig',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
|
@ -13,9 +13,7 @@ Including another URLconf
|
|||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue