def test_decrement_seconds_3_times_is_10_minutes_45_seconds(self):
     time_options_manager = TimeOptionsManager()
     time_options_manager.decrement_seconds()
     time_options_manager.decrement_seconds()
     time_options_manager.decrement_seconds()
     result = time_options_manager.get_time_string()
     self.assertEqual(result, "10:15")
示例#2
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        # self.iconbitmap(default='C:\\Users\\Chris\\OneDrive\\Git\\Pycharm\\MobTimer\\time-bomb.ico')
        #TODO: iconbitmap needs to load the ico file as a string because of py2exe =/
        self.time_options_manager = TimeOptionsManager()
        self.mobber_manager = MobberManager()
        self.countdown_manager = CountdownManager(self)
        self.session_manager = SessionManager(uuid)
        atexit.register(self.session_manager.clear_sessions)
        if self.session_manager.get_active_sessions().__len__() > 0:
            self.quit_and_destroy_session()

        self.session_manager.create_session()

        self.countdown_manager.subscribe_to_time_changes(
            self.show_screen_blocker_when_session_interupted)

        monitors = get_monitors()
        num_monitors = monitors.__len__()
        self.containers = [self]
        for monitor_index in range(1, num_monitors):
            monitor_screen_blocker = Toplevel(self)
            self.containers.append(monitor_screen_blocker)
        self.frame_types = (ScreenBlockerFrame, TransparentCountdownFrame)
        self.frames = {}
        for frame_type in self.frame_types:
            self.frames[frame_type] = []
        for container in self.containers:
            container_frame = Frame(container)
            container_frame.grid(row=0, column=0, sticky=N + S + E + W)
            container_frame.grid_rowconfigure(0, weight=1)
            container_frame.grid_columnconfigure(0, weight=1)
            for frame_type in self.frame_types:
                frame_instance = frame_type(container_frame, self,
                                            self.time_options_manager,
                                            self.mobber_manager,
                                            self.countdown_manager)
                self.frames[frame_type].append(frame_instance)
                frame_instance.grid(row=0, column=0, sticky="nsew")
        self.last_frame = None
        self.show_screen_blocker_frame()
        for frame_instance in self.frames[TransparentCountdownFrame]:
            frame_instance.bind("<Enter>",
                                self.toggle_transparent_frame_position)
        self.transparent_frame_position = 0
        self.title("Mob Timer")
    def test_subscribe_to_time_changes(self):
        time_options_manager = TimeOptionsManager()
        result = {"result": "time"}

        def time_change_callback(time, minutes, seconds):
            result["result"] += " " + time

        time_options_manager.subscribe_to_timechange(time_change_callback)

        time_options_manager.increment_seconds()

        self.assertEqual(result["result"], "time 10:00 10:15")
    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())
 def test_decrement_minutes_once_is_9_minutes(self):
     time_options_manager = TimeOptionsManager()
     time_options_manager.decrement_minutes()
     result = time_options_manager.get_time_string()
     self.assertEqual(result, "09:00")
 def test_default_time_10_minutes(self):
     time_options_manager = TimeOptionsManager()
     result = time_options_manager.get_time_string()
     self.assertEqual(result, "10:00")