Projet de remplacement du "RPiPasserelle" d'Otec.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_variable.py 1.1KB

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