mirror of
https://github.com/daniviga/bite.git
synced 2024-12-23 00:31:25 +01:00
Complete API renaming into DPS. Add sample local_settings
This commit is contained in:
parent
79f5c516e0
commit
e4d6a15614
20
bite/bite/local_settings.py.sample
Normal file
20
bite/bite/local_settings.py.sample
Normal file
@ -0,0 +1,20 @@
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'bite',
|
||||
'USER': 'bite',
|
||||
'PASSWORD': 'password',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
|
||||
MQTT_BROKER = {
|
||||
'HOST': 'localhost',
|
||||
'PORT': '1883',
|
||||
}
|
||||
|
||||
KAFKA_BROKER = {
|
||||
'HOST': 'localhost',
|
||||
'PORT': '29092',
|
||||
}
|
@ -61,7 +61,7 @@ INSTALLED_APPS = [
|
||||
# 'health_check.storage',
|
||||
'rest_framework',
|
||||
'bite',
|
||||
'api',
|
||||
'dps',
|
||||
'telemetry',
|
||||
]
|
||||
|
||||
|
@ -37,13 +37,13 @@ from django.contrib import admin
|
||||
from django.conf import settings
|
||||
from django.urls import include, path
|
||||
|
||||
from api import urls as api_urls
|
||||
from dps import urls as dps_urls
|
||||
from telemetry import urls as telemetry_urls
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('ht/', include('health_check.urls')),
|
||||
path('api/', include(api_urls)),
|
||||
path('dps/', include(dps_urls)),
|
||||
path('telemetry/', include(telemetry_urls)),
|
||||
]
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.contrib import admin
|
||||
from api.models import Device, WhiteList
|
||||
from dps.models import Device, WhiteList
|
||||
|
||||
|
||||
@admin.register(Device)
|
@ -20,5 +20,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiConfig(AppConfig):
|
||||
name = 'api'
|
||||
class DPSConfig(AppConfig):
|
||||
name = 'dps'
|
@ -1,6 +1,6 @@
|
||||
# Generated by Django 3.1.3 on 2021-03-19 08:08
|
||||
|
||||
import api.models
|
||||
import dps.models
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
|
||||
migrations.CreateModel(
|
||||
name='Device',
|
||||
fields=[
|
||||
('serial', models.CharField(max_length=128, unique=True, validators=[api.models.device_validation])),
|
||||
('serial', models.CharField(max_length=128, unique=True, validators=[dps.models.device_validation])),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('creation_time', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_time', models.DateTimeField(auto_now=True)),
|
@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from rest_framework import serializers
|
||||
from api.models import Device, device_validation
|
||||
from dps.models import Device, device_validation
|
||||
|
||||
|
||||
class DeviceSerializer(serializers.ModelSerializer):
|
@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from api.models import Device, WhiteList
|
||||
from dps.models import Device, WhiteList
|
||||
|
||||
|
||||
class DPSTestCase(TestCase):
|
||||
@ -29,17 +29,17 @@ class DPSTestCase(TestCase):
|
||||
Device.objects.create(serial='test1234')
|
||||
|
||||
def test_no_whitelist(self):
|
||||
response = self.c.post('/api/device/provision/',
|
||||
response = self.c.post('/dps/device/provision/',
|
||||
{'serial': 'test12345'})
|
||||
self.assertEqual(response.status_code, 400)
|
||||
|
||||
def test_provision_post(self):
|
||||
WhiteList.objects.create(serial='test12345')
|
||||
response = self.c.post('/api/device/provision/',
|
||||
response = self.c.post('/dps/device/provision/',
|
||||
{'serial': 'test12345'})
|
||||
self.assertEqual(response.status_code, 201)
|
||||
|
||||
def test_provision_get(self):
|
||||
response = self.c.get('/api/device/list/')
|
||||
response = self.c.get('/dps/device/list/')
|
||||
self.assertEqual(
|
||||
response.json()[0]['serial'], 'test1234')
|
@ -33,7 +33,7 @@ Including another URLconf
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.urls import path
|
||||
from api.views import DPS
|
||||
from dps.views import DPS
|
||||
|
||||
urlpatterns = [
|
||||
path('device/provision/',
|
@ -19,8 +19,8 @@
|
||||
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from api.models import Device
|
||||
from api.serializers import DeviceSerializer
|
||||
from dps.models import Device
|
||||
from dps.serializers import DeviceSerializer
|
||||
|
||||
|
||||
class DPS(ModelViewSet):
|
@ -31,7 +31,7 @@ from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from api.models import Device
|
||||
from dps.models import Device
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -26,7 +26,7 @@ from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from api.models import Device
|
||||
from dps.models import Device
|
||||
from telemetry.models import Telemetry
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('api', '0001_initial'),
|
||||
('dps', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
@ -23,7 +23,7 @@ class Migration(migrations.Migration):
|
||||
('transport', models.CharField(choices=[('http', 'http'), ('mqtt', 'mqtt')], default='http', max_length=4)),
|
||||
('clock', models.IntegerField(null=True, validators=[django.core.validators.MinValueValidator(0)])),
|
||||
('payload', models.JSONField(validators=[telemetry.models.telemetry_validation])),
|
||||
('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.device')),
|
||||
('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dps.device')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Telemetry',
|
||||
|
@ -21,7 +21,7 @@ from django.db import models
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from api.models import Device
|
||||
from dps.models import Device
|
||||
|
||||
|
||||
def telemetry_validation(value):
|
||||
|
@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from rest_framework import serializers
|
||||
from api.models import Device
|
||||
from dps.models import Device
|
||||
from telemetry.models import Telemetry
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
import json
|
||||
from django.test import TestCase, Client
|
||||
from api.models import Device, WhiteList
|
||||
from dps.models import Device, WhiteList
|
||||
|
||||
|
||||
class ApiTestCase(TestCase):
|
||||
|
@ -114,7 +114,7 @@ def main():
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
dps = "/api/device/provision/"
|
||||
dps = "/dps/device/provision/"
|
||||
telemetry = "/telemetry/"
|
||||
|
||||
if args.serial is None:
|
||||
|
Loading…
Reference in New Issue
Block a user