def test_working_hours_attribute_is_not_a_dictionary(): """testing if a TypeError will be raised when the working_hours attribute is set to a value which is not a dictionary """ wh = WorkingHours() with pytest.raises(TypeError) as cm: wh.working_hours = 'not a dictionary of proper values' assert str(cm.value) == \ 'WorkingHours.working_hours should be a dictionary, not str'
def test_working_hours_attribute_is_working_properly(self): """testing if the working_hours attribute is working properly """ working_hours = copy.copy(defaults.working_hours) working_hours["sun"] = [[540, 1000]] working_hours["sat"] = [[500, 800], [900, 1440]] wh = WorkingHours() wh.working_hours = working_hours self.assertEqual(wh.working_hours, working_hours) self.assertEqual(wh.working_hours["sun"], working_hours["sun"]) self.assertEqual(wh.working_hours["sat"], working_hours["sat"])
def test_working_hours_attribute_is_working_properly(self): """testing if the working_hours attribute is working properly """ working_hours = copy.copy(defaults.working_hours) working_hours['sun'] = [[540, 1000]] working_hours['sat'] = [[500, 800], [900, 1440]] wh = WorkingHours() wh.working_hours = working_hours self.assertEqual(wh.working_hours, working_hours) self.assertEqual(wh.working_hours['sun'], working_hours['sun']) self.assertEqual(wh.working_hours['sat'], working_hours['sat'])
def test_working_hours_attribute_is_not_a_dictionary(self): """testing if a TypeError will be raised when the working_hours attribute is set to a value which is not a dictionary """ wh = WorkingHours() with self.assertRaises(TypeError) as cm: wh.working_hours = 'not a dictionary of proper values' self.assertEqual( str(cm.exception), 'WorkingHours.working_hours should be a dictionary, not str')
def test_working_hours_attribute_value_is_not_complete(self): """testing if the default values are going to be used for missing days in the given working_hours attribute """ working_hours = {"sat": [[900, 1080]], "sun": [[900, 1080]]} wh = WorkingHours() wh.working_hours = working_hours self.assertEqual(wh["mon"], defaults.working_hours["mon"]) self.assertEqual(wh["tue"], defaults.working_hours["tue"]) self.assertEqual(wh["wed"], defaults.working_hours["wed"]) self.assertEqual(wh["thu"], defaults.working_hours["thu"]) self.assertEqual(wh["fri"], defaults.working_hours["fri"])
def test_working_hours_attribute_value_is_not_complete(self): """testing if the default values are going to be used for missing days in the given working_hours attribute """ working_hours = {'sat': [[900, 1080]], 'sun': [[900, 1080]]} wh = WorkingHours() wh.working_hours = working_hours self.assertEqual(wh['mon'], defaults.working_hours['mon']) self.assertEqual(wh['tue'], defaults.working_hours['tue']) self.assertEqual(wh['wed'], defaults.working_hours['wed']) self.assertEqual(wh['thu'], defaults.working_hours['thu']) self.assertEqual(wh['fri'], defaults.working_hours['fri'])
def test_working_hours_attribute_is_working_properly(): """testing if the working_hours attribute is working properly """ import copy from stalker import defaults working_hours = copy.copy(defaults.working_hours) working_hours['sun'] = [[540, 1000]] working_hours['sat'] = [[500, 800], [900, 1440]] wh = WorkingHours() wh.working_hours = working_hours assert wh.working_hours == working_hours assert wh.working_hours['sun'] == working_hours['sun'] assert wh.working_hours['sat'] == working_hours['sat']
def test_working_hours_attribute_value_is_not_complete(): """testing if the default values are going to be used for missing days in the given working_hours attribute """ working_hours = {'sat': [[900, 1080]], 'sun': [[900, 1080]]} wh = WorkingHours() wh.working_hours = working_hours from stalker import defaults assert wh['mon'] == defaults.working_hours['mon'] assert wh['tue'] == defaults.working_hours['tue'] assert wh['wed'] == defaults.working_hours['wed'] assert wh['thu'] == defaults.working_hours['thu'] assert wh['fri'] == defaults.working_hours['fri']
def test_working_hours_attribute_is_set_to_a_dictionary_of_other_formatted_data(): """testing if a TypeError will be raised when the working hours attribute value is a dictionary of some other value """ wh = WorkingHours() with pytest.raises(TypeError) as cm: wh.working_hours = {'not': 'properly valued'} assert str(cm.value) == \ 'WorkingHours.working_hours should be a dictionary with keys ' \ '"mon, tue, wed, thu, fri, sat, sun" and the values should a ' \ 'list of lists of two integers like [[540, 720], [800, 1080]], ' \ 'not str'
def test_working_hours_attribute_value_is_not_complete(self): """testing if the default values are going to be used for missing days in the given working_hours attribute """ working_hours = { 'sat': [[900, 1080]], 'sun': [[900, 1080]] } wh = WorkingHours() wh.working_hours = working_hours self.assertEqual(wh['mon'], defaults.working_hours['mon']) self.assertEqual(wh['tue'], defaults.working_hours['tue']) self.assertEqual(wh['wed'], defaults.working_hours['wed']) self.assertEqual(wh['thu'], defaults.working_hours['thu']) self.assertEqual(wh['fri'], defaults.working_hours['fri'])
def test_working_hours_attribute_data_is_not_in_correct_range2(): """testing if a ValueError will be raised if the range of the time values are not correct when setting the working_hours attr """ import copy from stalker import defaults wh_ins = WorkingHours() wh = copy.copy(defaults.working_hours) wh['sat'] = [[900, 1080], [1090, 1500]] with pytest.raises(ValueError) as cm: wh_ins.working_hours = wh assert str(cm.value) == \ 'WorkingHours.working_hours value should be a list of lists of ' \ 'two integers between and the range of integers should be 0-1440, ' \ 'not [[900, 1080], [1090, 1500]]'
def test_working_hours_attribute_data_is_not_in_correct_range1(self): """testing if a ValueError will be raised if the range of the time values are not correct when setting the working_hours attr """ import copy from stalker import defaults wh = copy.copy(defaults.working_hours) wh['sun'] = [[-10, 1000]] wh_ins = WorkingHours() with self.assertRaises(ValueError) as cm: wh_ins.working_hours = wh self.assertEqual( str(cm.exception), 'WorkingHours.working_hours value should be a list of lists of ' 'two integers between and the range of integers should be 0-1440, ' 'not [[-10, 1000]]')