def setUp(self): self.dm = DiabetManager() self.person_manager = self.dm.get_person_manager() self.person_one_data = { 'name': 'Alice', 'default_basal_rate': '0.7', }
def setUp(self): self.dm = DiabetManager() self.person = Person(person_one_data) self.bg_manager = self.dm.get_blood_glucose_manager() self.bg_value = 124 self.bg_hour = 14 self.bg_state = self.bg_manager.create_bg_state( self.person, self.bg_value, self.bg_hour)
def setUp(self): self.dm = DiabetManager() self.person = Person(person_one_data) self.bg_manager = self.dm.get_blood_glucose_manager() self.bg_value = 124 self.bg_hour = 14 self.bg_state = self.bg_manager.create_bg_state(self.person, self.bg_value, self.bg_hour)
class BGManagerTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() self.person = Person(person_one_data) self.bg_manager = self.dm.get_blood_glucose_manager() def test_get_diabet_manager(self): self.assertEqual(self.dm, self.bg_manager.get_diabet_manager()) def test_create_bg_status(self): level = self.bg_manager.create_bg_state(self.person, 124, 14) self.assertTrue(isinstance(level, BGState))
class DiabetManagerTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() def test_diabet_manager(self): dm = DiabetManager() def test_get_person_manager(self): pm = self.dm.get_person_manager() self.assertTrue(isinstance(pm, PersonManager)) def test_get_bolus_manager(self): pm = self.dm.get_bolus_manager() self.assertTrue(isinstance(pm, BolusManager)) def test_get_bolus_history_manager(self): pm = self.dm.get_bolus_history_manager() self.assertTrue(isinstance(pm, BolusHistoryManager)) def test_get_blood_glucose_manager(self): bgm = self.dm.get_blood_glucose_manager() self.assertTrue(isinstance(bgm, BGManager))
class PersonManagerTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() self.person_manager = self.dm.get_person_manager() self.person_one_data = { 'name': 'Alice', 'default_basal_rate': '0.7', } def test_get_diabet_manager(self): self.assertEqual(self.dm, self.person_manager.get_diabet_manager()) def test_get_person_by_name(self): person = Person(self.person_one_data) self.person_manager.save_person(person) name = 'Alice' new_person = self.person_manager.get_person_by_name(name) self.assertEqual(new_person.get_name(), name) def test_get_person_by_name_invalid_name(self): try: new_person = self.person_manager.get_person_by_name('NoSuchName') self.assertIsNone(new_person) except NoSuchPersonException: pass def test_save_person_create(self): person = Person(self.person_one_data) self.person_manager.save_person(person) def test_save_person_create_invalid_name(self): person = Person() try: self.person_manager.save_person(person) except ValueException: pass def test_save_person_update(self): person = Person(self.person_one_data) self.person_manager.save_person(person) # set new default_basal_rate new_rate = 0.9 person.set_default_basal_rate(new_rate) self.person_manager.save_person(person) new_person = self.person_manager.get_person_by_name('Alice') self.assertEqual(new_person.get_default_basal_rate(), new_rate)
class BGLevelTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() self.person = Person(person_one_data) self.bg_manager = self.dm.get_blood_glucose_manager() self.bg_value = 124 self.bg_hour = 14 self.bg_state = self.bg_manager.create_bg_state( self.person, self.bg_value, self.bg_hour) def test_get_person(self): person = self.bg_state.get_person() self.assertEqual(person, self.person) def test_get_value(self): value = self.bg_state.get_value() self.assertEqual(value, self.bg_value) def test_get_hour(self): hour = self.bg_state.get_hour() self.assertEqual(hour, self.bg_hour)
class BGLevelTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() self.person = Person(person_one_data) self.bg_manager = self.dm.get_blood_glucose_manager() self.bg_value = 124 self.bg_hour = 14 self.bg_state = self.bg_manager.create_bg_state(self.person, self.bg_value, self.bg_hour) def test_get_person(self): person = self.bg_state.get_person() self.assertEqual(person, self.person) def test_get_value(self): value = self.bg_state.get_value() self.assertEqual(value, self.bg_value) def test_get_hour(self): hour = self.bg_state.get_hour() self.assertEqual(hour, self.bg_hour)
def setUp(self): self.dm = DiabetManager() self.person_manager = self.dm.get_person_manager() self.person_one = Person(person_one_data)
class PersonTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() self.person_manager = self.dm.get_person_manager() self.person_one = Person(person_one_data) def test_get_name(self): self.assertEqual(self.person_one.get_name(), person_one_data['name']) def test_get_default_basal_rate(self): self.assertEqual(self.person_one.get_default_basal_rate(), float(person_one_data['default_basal_rate'])) def test_set_default_basal_rate(self): self.person_one.set_default_basal_rate(0.9) self.assertEqual(self.person_one.get_default_basal_rate(), 0.9) def test_set_basal_rate_at(self): self.person_one.set_basal_rate_at(0.7, 3) self.person_one.set_basal_rate_at(0.6, 9) def test_get_basal_rate_at(self): self.person_one.set_basal_rate_at(0.7, 3) self.person_one.set_basal_rate_at(0.6, 9) self.assertEqual(self.person_one.get_basal_rate_at(3), 0.7) self.assertEqual(self.person_one.get_basal_rate_at(9), 0.6) def test_set_default_icr(self): self.person_one.set_default_icr(7) def test_set_default_icr_invalid(self): try: self.person_one.set_default_icr(-1) except ValueException: pass def test_get_default_icr(self): icr = 9 self.person_one.set_default_icr(icr) self.assertEqual(self.person_one.get_default_icr(), icr) def test_set_icr_at(self): self.person_one.set_icr_at(7, 3) self.person_one.set_icr_at(6, 9) def test_get_icr_at(self): self.person_one.set_icr_at(7, 3) self.person_one.set_icr_at(6, 9) self.assertEqual(self.person_one.get_icr_at(3), 7) self.assertEqual(self.person_one.get_icr_at(9), 6) def test_set_default_isf(self): self.person_one.set_default_isf(30) def test_set_default_isf_invalid(self): try: self.person_one.set_default_isf(-1) except ValueException: pass def test_get_default_isf(self): isf = 9 self.person_one.set_default_isf(isf) self.assertEqual(self.person_one.get_default_isf(), isf) def test_get_timezone(self): tz = self.person_one.get_timezone() self.assertEqual(tz.zone, person_one_data['timezone']) def test_set_timezone(self): tz = timezone('Europe/Madrid') self.person_one.set_timezone(tz) new_tz = self.person_one.get_timezone() self.assertEqual(tz.zone, new_tz.zone) def test_set_timezone_invalid_type(self): try: self.person_one.set_timezone('Europe/Madrid') except ValueException: pass def test_set_timezone_none(self): try: self.person_one.set_timezone(None) except ValueException: pass def test_set_measure_mg(self): self.person_one.set_measure_mg(True) def test_has_measure_mg(self): self.person_one.set_measure_mg(True) self.assertTrue(self.person_one.has_measure_mg()) self.person_one.set_measure_mg(False) self.assertFalse(self.person_one.has_measure_mg())
class BolusManagerTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() self.person_manager = self.dm.get_person_manager() self.person = Person(person_one_data) self.bolus_manager = self.dm.get_bolus_manager() def test_get_diabet_manager(self): self.assertEqual(self.dm, self.bolus_manager.get_diabet_manager()) def test_calculate_bolus(self): expected_bolus = 6.9 expected_extended_bolus = 1.1 # chicken, pineapple, pepper, rise, olive oil meal = Meal('chicken', 55, 8, 27) bg_state = self.dm.get_blood_glucose_manager().create_bg_state( self.person, 100, 14) bolus = self.dm.get_bolus_manager().calculate_bolus(bg_state, meal) self.assertEqual(bolus.get_value(), expected_bolus) self.assertEqual(bolus.get_extended_value(), expected_extended_bolus) def test_calculate_bolus_with_low_blood_glucose_level_mmol_set(self): # calculate bolus but suggest different one taking correction into account # set mmol measure for person unittest.SkipTest() def test_calculate_bolus_with_low_blood_glucose_level_mg_set(self): # calculate bolus but suggest different one taking correction into account # set mg/dL measure for person unittest.SkipTest() def test_calculate_bolus_with_high_blood_glucose_level_mmol_set(self): # calculate bolus but suggest different one taking correction into account # set mmol measure for person unittest.SkipTest() def test_calculate_bolus_with_high_blood_glucose_level_mg_set(self): # calculate bolus but suggest different one taking correction into account # set mg/dL measure for person unittest.SkipTest() def test_calculate_bolus_in_the_morning(self): expected_bolus = 4.8 expected_extended_bolus = 0.8 # bread, cheese, pineapple meal = Meal('breakfast', 43, 12, 9) bg_state = self.dm.get_blood_glucose_manager().create_bg_state( self.person, 100, 9) bolus = self.dm.get_bolus_manager().calculate_bolus(bg_state, meal) self.assertEqual(bolus.get_value(), expected_bolus) self.assertEqual(bolus.get_extended_value(), expected_extended_bolus) def test_calculate_bolus_in_the_evening(self): expected_bolus = round(2.25, 1) expected_extended_bolus = 0.4 # fruits, seeds meal = Meal('fruits', 18, 5, 3) bg_state = self.dm.get_blood_glucose_manager().create_bg_state( self.person, 100, 17) bolus = self.dm.get_bolus_manager().calculate_bolus(bg_state, meal) self.assertEqual(bolus.get_value(), expected_bolus) self.assertEqual(bolus.get_extended_value(), expected_extended_bolus)
def setUp(self): self.dm = DiabetManager()
def setUp(self): self.dm = DiabetManager() self.person = Person(person_one_data) self.bg_manager = self.dm.get_blood_glucose_manager()
def test_diabet_manager(self): dm = DiabetManager()
class BolusManagerTest(unittest.TestCase): def setUp(self): self.dm = DiabetManager() self.person_manager = self.dm.get_person_manager() self.person = Person(person_one_data) self.bolus_manager = self.dm.get_bolus_manager() def test_get_diabet_manager(self): self.assertEqual(self.dm, self.bolus_manager.get_diabet_manager()) def test_calculate_bolus(self): expected_bolus = 6.9 expected_extended_bolus = 1.1 # chicken, pineapple, pepper, rise, olive oil meal = Meal('chicken', 55, 8, 27) bg_state = self.dm.get_blood_glucose_manager().create_bg_state(self.person, 100, 14) bolus = self.dm.get_bolus_manager().calculate_bolus(bg_state, meal) self.assertEqual(bolus.get_value(), expected_bolus) self.assertEqual(bolus.get_extended_value(), expected_extended_bolus) def test_calculate_bolus_with_low_blood_glucose_level_mmol_set(self): # calculate bolus but suggest different one taking correction into account # set mmol measure for person unittest.SkipTest() def test_calculate_bolus_with_low_blood_glucose_level_mg_set(self): # calculate bolus but suggest different one taking correction into account # set mg/dL measure for person unittest.SkipTest() def test_calculate_bolus_with_high_blood_glucose_level_mmol_set(self): # calculate bolus but suggest different one taking correction into account # set mmol measure for person unittest.SkipTest() def test_calculate_bolus_with_high_blood_glucose_level_mg_set(self): # calculate bolus but suggest different one taking correction into account # set mg/dL measure for person unittest.SkipTest() def test_calculate_bolus_in_the_morning(self): expected_bolus = 4.8 expected_extended_bolus = 0.8 # bread, cheese, pineapple meal = Meal('breakfast', 43, 12, 9) bg_state = self.dm.get_blood_glucose_manager().create_bg_state(self.person, 100, 9) bolus = self.dm.get_bolus_manager().calculate_bolus(bg_state, meal) self.assertEqual(bolus.get_value(), expected_bolus) self.assertEqual(bolus.get_extended_value(), expected_extended_bolus) def test_calculate_bolus_in_the_evening(self): expected_bolus = round(2.25, 1) expected_extended_bolus = 0.4 # fruits, seeds meal = Meal('fruits', 18, 5, 3) bg_state = self.dm.get_blood_glucose_manager().create_bg_state(self.person, 100, 17) bolus = self.dm.get_bolus_manager().calculate_bolus(bg_state, meal) self.assertEqual(bolus.get_value(), expected_bolus) self.assertEqual(bolus.get_extended_value(), expected_extended_bolus)