コード例 #1
0
    def test_subscribe_to_time_changes_complex(self):
        time_options_manager = TimeOptionsManager()
        result = {"result": "Time Options after Change:", "increment": 0}

        def time_change_callback(time, minutes, seconds):
            result["increment"] += 1
            result["result"] += "\n Change " + result["increment"].__str__(
            ) + "| " + time

        time_options_manager.subscribe_to_timechange(time_change_callback)

        time_options_manager.increment_seconds()
        time_options_manager.increment_seconds()
        time_options_manager.increment_seconds()
        time_options_manager.decrement_seconds()
        time_options_manager.decrement_seconds()
        time_options_manager.decrement_seconds()
        time_options_manager.decrement_seconds()
        time_options_manager.decrement_minutes()
        time_options_manager.decrement_minutes()
        time_options_manager.increment_minutes()
        time_options_manager.increment_minutes()
        time_options_manager.increment_minutes()
        time_options_manager.increment_minutes()
        time_options_manager.increment_minutes()

        Approvals.verify(result["result"], TextDiffReporter())
コード例 #2
0
    def test_subscribe_to_mobber_list_changes(self):
        mobber_manager = MobberManager()
        result = {
            "result": "Mobbers in List for Each Change\n",
            "increment": 0
        }

        def time_change_callback(mobber_list, driver_index, navigator_index):
            result["increment"] += 1
            result["result"] += "Action " + result["increment"].__str__() + ":"
            for mobber_index in range(0, mobber_list.__len__()):
                result["result"] += mobber_list[mobber_index]
                if mobber_index == driver_index:
                    result["result"] += " (Driver)"
                if mobber_index == navigator_index:
                    result["result"] += " (Navigator)"
                result["result"] += ", "

            result["result"] += "\n"

        mobber_manager.subscribe_to_mobber_list_change(time_change_callback)

        mobber_manager.add_mobber("Joe")
        mobber_manager.add_mobber("Chris")
        mobber_manager.add_mobber("Sam")
        mobber_manager.add_mobber("John")
        mobber_manager.switch_next_driver()
        mobber_manager.add_mobber("Bill")
        mobber_manager.switch_next_driver()
        mobber_manager.switch_next_driver()
        mobber_manager.switch_next_driver()
        mobber_manager.switch_next_driver()
        mobber_manager.switch_next_driver()
        mobber_manager.remove_mobber(2)
        mobber_manager.remove_mobber(0)
        mobber_manager.switch_next_driver()
        mobber_manager.rewind_driver()
        mobber_manager.add_mobber("Seth")
        mobber_manager.rewind_driver()
        mobber_manager.rewind_driver()
        mobber_manager.rewind_driver()
        mobber_manager.move_mobber_down(0)
        mobber_manager.add_mobber("Fredrick")
        mobber_manager.move_mobber_up(2)
        mobber_manager.remove_mobber(1)
        mobber_manager.remove_mobber(0)
        mobber_manager.remove_mobber(0)

        Approvals.verify(result["result"], TextDiffReporter())
コード例 #3
0
    def test_subscribe_to_time_changes(self):
        countdown_manager = CountdownManager(None)
        result = {"result": "Times changed to\n", "increment": 0}

        def time_change_callback(days, minutes, seconds):
            result["increment"] += 1
            result["result"] += "Action " + result["increment"].__str__() + ":"
            result["result"] += "    {0:0>2}:{1:0>2}".format(minutes,
                                                             seconds) + "\n"

        countdown_manager.subscribe_to_time_changes(time_change_callback)
        countdown_manager.set_countdown_duration(4, 42)
        countdown_manager.set_countdown_duration(603, 52)
        countdown_manager.set_countdown_duration(1, 3)
        countdown_manager.set_countdown_duration(853, 32)
        countdown_manager.set_countdown_duration(3, 62)

        Approvals.verify(result["result"], TextDiffReporter())
コード例 #4
0
 def test(self):
     reporter = TextDiffReporter()
     approvals.verify("x", reporter)
コード例 #5
0
 def instantiate_reporter_for_test():
     reporter = TextDiffReporter()
     reporter.run_command = lambda command_array: None
     return reporter