def test_left_key_returns_none(self): db = DialogBox("ync", get_mock_input(), get_mock_output(), name=db_name) db.refresh = lambda *args, **kwargs: None # Checking at the start of the options def scenario(): db.move_left() assert not db.in_foreground with patch.object(db, 'idle_loop', side_effect=scenario) as p: return_value = db.activate() assert return_value is None # Going to the right and then going to the left again def scenario(): db.move_right() db.move_left() #At this point, shouldn't exit assert db.in_foreground db.move_left() assert not db.in_foreground with patch.object(db, 'idle_loop', side_effect=scenario) as p: return_value = db.activate() assert return_value is None
def test_start_option(self): db = DialogBox("ync", get_mock_input(), get_mock_output(), name=db_name) db.refresh = lambda *args, **kwargs: None db.set_start_option(1) #So, "No" option would be selected def scenario(): db.accept_value() # KEY_ENTER assert not db.in_foreground # Should exit with patch.object(db, 'idle_loop', side_effect=scenario) as p: return_value = db.activate() assert return_value is False #Second element - No, means False