Projet de remplacement du "RPiPasserelle" d'Otec.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

test_variable_values.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python3
  2. import pytest
  3. from starlette.exceptions import HTTPException
  4. from starlette.testclient import TestClient
  5. from datetime import datetime, timedelta
  6. from pyheatpump.variables import app, get_variables, set_variables, ROUTES
  7. from pyheatpump.variable_values import app, get_variable_value, set_variable_value, ROUTES
  8. def test_get_type_address(set_test_db):
  9. c = TestClient(app)
  10. r = c.get('/A/10')
  11. assert r.status_code == 200
  12. d_resp = r.content.decode()
  13. assert int(d_resp) == 42
  14. try:
  15. r = c.get('/X/10')
  16. except HTTPException as e:
  17. assert e.status_code == 404
  18. r = c.get('/A/10/{}'.format(
  19. (datetime.now() - timedelta(days=1)).isoformat()
  20. ))
  21. d_resp = r.content.decode()
  22. assert int(d_resp) == 20
  23. r = c.get('/A/10/{}'.format(
  24. (datetime.now() - timedelta(days=2)).isoformat()
  25. ))
  26. d_resp = r.content.decode()
  27. assert int(d_resp) == 0
  28. r = c.get('/I/5010')
  29. d_resp = r.content.decode()
  30. assert int(d_resp) == 42
  31. r = c.get('/I/5011')
  32. d_resp = r.content.decode()
  33. assert int(d_resp) == 24
  34. r = c.get('/I/5010/{}'.format(
  35. (datetime.now() - timedelta(hours=1)).isoformat()
  36. ))
  37. d_resp = r.content.decode()
  38. assert int(d_resp) == 20
  39. r = c.get('/I/5010/{}'.format(
  40. (datetime.now() - timedelta(hours=2)).isoformat()
  41. ))
  42. d_resp = r.content.decode()
  43. assert int(d_resp) == 0
  44. @pytest.mark.skip
  45. def test_set_(set_test_db):
  46. c = TestClient(app)
  47. r = c.post('/')
  48. assert r.status_code == 200