def test_run__validate_time_slot(self): """ This method tests the ability of the runs table to validate a time slot, making sure it is viable for using on the table and throwing the appropriate exception if not. The expected result of this test is for the given time slot to be validated as correct. """ # Set a time slot to be tested time_slot = datetime.datetime.now().replace(minute=5) + datetime.timedelta(hours=1) # Assert that the validation does not call an exception, and so the time slot is correct try: Run._validate_time_slot(datetime.datetime.now(), time_slot) except RunSlotInvalidError: raise Exception("test_run__validate_time_slot has failed")
def test_run__validate_time_slot_not_five(self): """ This method tests the ability of the runs table to validate a time slot, making sure it is viable for using on the table and throwing the appropriate exception if not. The expected result of this test is for the given time slot to be validated as not a multiple of five. """ # Set a time slot to be tested time_slot = datetime.datetime.now().replace(minute=6) + datetime.timedelta(days=1) # Assert that the validation calls an exception because the time slot is not a multiple of five try: Run._validate_time_slot(datetime.datetime.now(), time_slot) except RunSlotInvalidError as e: # Assert that the correct error has been thrown assert e # Assert that it has been thrown for the right reason assert e.args[0] == "Minute value is not a multiple of 5"
def test_run__validate_time_slot_with_start(self): """ This method tests the ability of the runs table to validate a time slot, making sure it is viable for using on the table and throwing the appropriate exception if not. The expected result of this test is for the given time slot to be validated as correct. """ project_config["start_date"] = datetime.date(year=2014, month=7, day=7) # Set a time slot to be tested time_slot = datetime.datetime.now().replace(year=2014, month=7, day=14, minute=5) # Assert that the validation does not call an exception, and so the time slot is correct try: Run._validate_time_slot(datetime.datetime.now(), time_slot) except RunSlotInvalidError: raise Exception("test_run__validate_time_slot_with_start has failed") project_config["start_date"] = None