Esempio n. 1
0
    def test_run_get_time_slots_for_day_with_runs(self):
        """
        This method tests the ability of the runs table to retrieve the available time slots in a given day. The
        expected result of this test is for the number of retrieved time slots to be equal to the number of five
        minute time slots in a day minus two (for two runs).
        """
        # Give the method a future date and receive correct no. of time-slots for that date
        date = datetime.date.today() + datetime.timedelta(days=2)

        min_time = project_config["starting_time"]
        max_time = project_config["closing_time"]
        # Calculate the no. of hours in a given day to test
        no_mins = (max_time.hour*60 + max_time.minute) - (min_time.hour*60 + min_time.minute)
        no_time_slots = math.ceil(no_mins / 5)

        date = datetime.datetime.combine(date, datetime.time(hour=12, minute=0, second=0, microsecond=0))

        runs = [
            Run(create_input_pattern(), date, self._insert_name),
            Run(create_input_pattern(), date + datetime.timedelta(minutes=5), self._insert_name)]
        with transaction.manager:
            DBSession.add_all(runs)
            DBSession.commit

        time_slots = Run.get_time_slots_for_day(date, datetime.datetime.now())

        # Assert that the correct number of available time slots have been retrieved.
        assert no_time_slots - len(runs) == len(time_slots)
Esempio n. 2
0
    def test_run_get_time_slots_for_day(self):
        """
        This method tests the ability of the runs table to retrieve the available time slots in a given day. The
        expected result of this test is for the number of retrieved time slots to be equal to the number of five minute
        time slots in a day.
        """
        # Give the method a future date and receive correct no. of time-slots for that date
        date = datetime.date.today() + datetime.timedelta(days=10)

        min_time = project_config["starting_time"]
        max_time = project_config["closing_time"]
        # Calculate the no. of hours in a given day to test
        no_mins = (max_time.hour*60 + max_time.minute) - (min_time.hour*60 + min_time.minute)
        no_time_slots = math.ceil(no_mins / 5)

        time_slots = Run.get_time_slots_for_day(date, datetime.datetime.now(), min_time, max_time)

        assert no_time_slots == len(time_slots)
Esempio n. 3
0
    def test_run_get_time_slots_for_day_non_hour(self):
        """
        This method tests the ability of the runs table to retrieve the number of available of time slots in a day. The
        expected result of this this test is that the correct number of available time slots for an hour is retrieved
        when there are no runs to be played in the given hour and the day does not end 'on the hour'.
        """
        # Give the method a future date
        date = datetime.date.today() + datetime.timedelta(days=11)

        min_time = datetime.time(hour=9, minute=0)
        max_time = datetime.time(hour=17, minute=0)

        # Calculate the no. of time slots in a given day
        no_mins = (max_time.hour*60 + max_time.minute) - (min_time.hour*60 + min_time.minute)
        no_time_slots = math.ceil(no_mins / 5)

        # Assert that the correct number of available time slots have been retrieved.
        time_slots = Run.get_time_slots_for_day(date, datetime.datetime.now(), min_time, max_time)

        # Assert that the correct number of time slots has been retrieved
        assert no_time_slots == len(time_slots)