Source code for iCalibrationDB.tests.test_operating_condition

from unittest import TestCase

from ..operating_condition import OperatingCondition


[docs]class TestOperatingCondition(TestCase):
[docs] def test_defaults(self): oc = OperatingCondition() self.assertFalse(oc.logarithmic) self.assertTrue(oc.available) self.assertIsNone(oc.value) self.assertIsNone(oc.name) self.assertIsNone(oc.description) self.assertIsNone(oc.lower_deviation) self.assertIsNone(oc.upper_deviation)
[docs] def test_typing(self): oc = OperatingCondition() # assigning string to float fields will raise with self.assertRaises(ValueError): oc.lower_deviation = "Foo" with self.assertRaises(ValueError): oc.upper_deviation = "Bar" with self.assertRaises(ValueError): oc.value = "Bar" # numbers will work oc.value = 1 self.assertEqual(oc.value, 1) oc.lower_deviation = 1 self.assertEqual(oc.lower_deviation, 1) oc.upper_deviation = 1 self.assertEqual(oc.upper_deviation, 1)
[docs] def test_to_dict(self): oc = OperatingCondition() oc.value = 1 oc.logarithmic = True oc.lower_deviation = 4 oc.upper_deviation = 5 # will raise with self.assertRaises(AttributeError): oc.to_dict() oc.name = "Foo" oc.description = "Hoo" self.assertEqual(oc.to_dict(), {'flg_available': True, 'lower_deviation_value': 4.0, 'upper_deviation_value': 5.0, 'description': 'Hoo', 'parameter_name': 'Foo', 'value': 1.0, 'flg_logarithmic': True})