|
@@ -0,0 +1,36 @@
|
|
1
|
+#!/usr/bin/env python3
|
|
2
|
+import pytest
|
|
3
|
+from datetime import datetime
|
|
4
|
+from random import choice
|
|
5
|
+
|
|
6
|
+from pyheatpump.models.variable import Variable
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+@pytest.fixture
|
|
10
|
+def rand_vars(set_test_db, var_types):
|
|
11
|
+ r = []
|
|
12
|
+ for _, var_type in var_types.items():
|
|
13
|
+ r.append( Variable(type=var_type,
|
|
14
|
+ address=choice(range(var_type.start_address, var_type.end_address))))
|
|
15
|
+ return r
|
|
16
|
+
|
|
17
|
+def test_insert(set_test_db, var_types, rand_vars):
|
|
18
|
+ for var in rand_vars:
|
|
19
|
+ var.insert()
|
|
20
|
+
|
|
21
|
+ assert var.exists()
|
|
22
|
+
|
|
23
|
+def test_getall_of_type(set_test_db, var_types):
|
|
24
|
+ for _, var_type in var_types.items():
|
|
25
|
+ assert isinstance(Variable.getall_of_type(var_type), dict)
|
|
26
|
+
|
|
27
|
+def test_getall(set_test_db):
|
|
28
|
+ assert isinstance(Variable.getall(), dict)
|
|
29
|
+
|
|
30
|
+def test_getall_values_of_type_since(set_test_db, var_types):
|
|
31
|
+ for _, var_type in var_types.items():
|
|
32
|
+ assert isinstance(Variable.getall_values_of_type_since(var_type, 0), dict)
|
|
33
|
+
|
|
34
|
+def test_getall_values_of_type(set_test_db, var_types):
|
|
35
|
+ for _, var_type in var_types.items():
|
|
36
|
+ assert isinstance(Variable.getall_values_of_type_since(var_type, 0), dict)
|