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
|
python3 sensors
|
||||||
|
|
||||||
test: venv/development
|
test: venv/development
|
||||||
pytest --cov=. --cov-report=term
|
pytest --cov=. --cov-report=term sensors/
|
||||||
|
|
||||||
venv/development:
|
venv/development:
|
||||||
test -d venv || python3 -m venv venv
|
test -d venv || python3 -m venv venv
|
||||||
( \
|
( \
|
||||||
source venv/bin/activate; \
|
source venv/bin/activate; \
|
||||||
pip3 install -e .; \
|
|
||||||
pip3 install -r requirements/development.txt; \
|
pip3 install -r requirements/development.txt; \
|
||||||
)
|
)
|
||||||
touch venv/development
|
touch venv/development
|
||||||
|
@ -21,7 +20,7 @@ venv:
|
||||||
test -d venv || python3 -m venv venv
|
test -d venv || python3 -m venv venv
|
||||||
( \
|
( \
|
||||||
source venv/bin/activate; \
|
source venv/bin/activate; \
|
||||||
pip3 install .; \
|
pip3 install -r requirements/base.txt; \
|
||||||
)
|
)
|
||||||
|
|
||||||
venv/bin/activate: venv
|
venv/bin/activate: venv
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
pytest
|
pytest
|
||||||
pytest-cov
|
pytest-cov
|
||||||
|
pytest-django
|
||||||
pep8
|
pep8
|
||||||
rope
|
rope
|
||||||
pylint
|
pylint
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
class Time(models.Model):
|
class Time(models.Model):
|
||||||
value = DateTimeField()
|
value = models.DateTimeField()
|
||||||
|
|
||||||
|
|
||||||
class Temperatur(models.Model):
|
class Temperatur(models.Model):
|
||||||
time = ForeignKeyField(Time, backref='temperatures')
|
time = models.ForeignKey(Time, on_delete=models.CASCADE)
|
||||||
value = FloatField()
|
value = models.FloatField()
|
||||||
|
|
||||||
|
|
||||||
class Humidity(models.Model):
|
class Humidity(models.Model):
|
||||||
time = ForeignKeyField(Time, backref='humidities')
|
time = models.ForeignKey(Time, on_delete=models.CASCADE)
|
||||||
value = FloatField()
|
value = models.FloatField()
|
||||||
|
|
||||||
|
|
||||||
class Pressure(models.Model):
|
class Pressure(models.Model):
|
||||||
time = ForeignKeyField(Time, backref='pressures')
|
time = models.ForeignKey(Time, on_delete=models.CASCADE)
|
||||||
value = FloatField()
|
value = models.FloatField()
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
import pytest
|
||||||
from django.test import TestCase
|
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.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'collector.apps.CollectorConfig',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
|
@ -13,9 +13,7 @@ Including another URLconf
|
||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue