added missing files
This commit is contained in:
parent
1cec93712c
commit
a98b164a4f
2 changed files with 57 additions and 0 deletions
32
caimira/tests/apps/calculator/test_report_json.py
Normal file
32
caimira/tests/apps/calculator/test_report_json.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import json
|
||||
|
||||
import tornado.testing
|
||||
|
||||
import caimira.apps.calculator
|
||||
from caimira.apps.calculator import model_generator
|
||||
|
||||
_TIMEOUT = 40.
|
||||
|
||||
|
||||
class TestCalculatorJsonResponse(tornado.testing.AsyncHTTPTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.http_client.defaults['request_timeout'] = _TIMEOUT
|
||||
|
||||
def get_app(self):
|
||||
return caimira.apps.calculator.make_app()
|
||||
|
||||
@tornado.testing.gen_test(timeout=_TIMEOUT)
|
||||
def test_json_response(self):
|
||||
response = yield self.http_client.fetch(
|
||||
request=self.get_url("/calculator/report-json"),
|
||||
method="POST",
|
||||
headers={'content-type': 'application/json'},
|
||||
body=json.dumps(model_generator.baseline_raw_form_data())
|
||||
)
|
||||
self.assertEqual(response.code, 200)
|
||||
|
||||
data = json.loads(response.body)
|
||||
self.assertIsInstance(data['prob_inf'], float)
|
||||
self.assertIsInstance(data['expected_new_cases'], float)
|
||||
|
||||
25
caimira/tests/models/test_virus.py
Normal file
25
caimira/tests/models/test_virus.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import numpy as np
|
||||
import numpy.testing as npt
|
||||
import pytest
|
||||
|
||||
from caimira import models
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"inside_temp, humidity, expected_halflife, expected_decay_constant",
|
||||
[
|
||||
[293.15, 0.5, 0.5947447349860315, 1.1654532436949188],
|
||||
[272.15, 0.7, 1.6070844193207476, 0.4313072619127947],
|
||||
[300.15, 1., 0.17367078830147223, 3.9911558376571805],
|
||||
[300.15, 0., 6.43, 0.10779893943389507],
|
||||
[np.array([272.15, 300.15]), np.array([0.7, 0.]),
|
||||
np.array([1.60708442, 6.43]), np.array([0.43130726, 0.10779894])],
|
||||
[np.array([293.15, 300.15]), np.array([0.5, 1.]),
|
||||
np.array([0.59474473, 0.17367079]), np.array([1.16545324, 3.99115584])]
|
||||
],
|
||||
)
|
||||
def test_decay_constant(inside_temp, humidity, expected_halflife, expected_decay_constant):
|
||||
npt.assert_almost_equal(models.Virus.types['SARS_CoV_2'].halflife(humidity, inside_temp),
|
||||
expected_halflife)
|
||||
npt.assert_almost_equal(models.Virus.types['SARS_CoV_2'].decay_constant(humidity, inside_temp),
|
||||
expected_decay_constant)
|
||||
Loading…
Reference in a new issue