123456789101112131415161718192021222324252627282930313233343536 |
- #!/usr/bin/env python3
- import pytest
- from datetime import datetime
- from random import choice
-
- from pyheatpump.models.variable import Variable
-
-
- @pytest.fixture
- def rand_vars(set_test_db, var_types):
- r = []
- for _, var_type in var_types.items():
- r.append( Variable(type=var_type,
- address=choice(range(var_type.start_address, var_type.end_address))))
- return r
-
- def test_insert(set_test_db, var_types, rand_vars):
- for var in rand_vars:
- var.insert()
-
- assert var.exists()
-
- def test_getall_of_type(set_test_db, var_types):
- for _, var_type in var_types.items():
- assert isinstance(Variable.getall_of_type(var_type), dict)
-
- def test_getall(set_test_db):
- assert isinstance(Variable.getall(), dict)
-
- def test_getall_values_of_type_since(set_test_db, var_types):
- for _, var_type in var_types.items():
- assert isinstance(Variable.getall_values_of_type_since(var_type, 0), dict)
-
- def test_getall_values_of_type(set_test_db, var_types):
- for _, var_type in var_types.items():
- assert isinstance(Variable.getall_values_of_type_since(var_type, 0), dict)
|