class QueueViewModel:
    def __init__(self):
        self.queue = Queue()
        self.input_info = ''
        self.arrived_info = ''
        self.set_arrive_btn_disabled()
        self.set_leave_btn_disabled()

    def set_arrive_btn_enabled(self):
        self.arrive_btn_state = 'normal'

    def set_arrive_btn_disabled(self):
        self.arrive_btn_state = 'disabled'

    def get_arrive_btn_state(self):
        return self.arrive_btn_state

    def set_leave_btn_enabled(self):
        self.leave_btn_state = 'normal'

    def set_leave_btn_disabled(self):
        self.leave_btn_state = 'disabled'

    def get_leave_btn_state(self):
        return self.leave_btn_state

    def get_input_info(self):
        return self.input_info

    def get_arrived_info(self):
        return self.arrived_info

    def set_input_info(self, input_info):
        self.input_info = input_info
        self.set_arrive_btn_enabled()
        self.set_leave_btn_enabled()

    def set_arrived_info(self, arrived_info):
        self.arrived_info = self.queue.get_elements()
        if self.queue.size() > 0:
            self.set_leave_btn_enabled()
        else:
            self.set_leave_btn_disabled()

    def arrive_btn_clicked(self):
        self.queue.add_to_queue(self.input_info)
        self.arrived_info = self.queue.get_elements()
        self.set_leave_btn_enabled()

    def leave_btn_clicked(self):
        self.queue.remove_from_queue()
        self.arrived_info = self.queue.get_elements()
Beispiel #2
0
 def test_can_remove_from_queue_third(self):
     queue = Queue()
     queue.add_to_queue('hello')
     queue.add_to_queue(13)
     queue.add_to_queue('wall')
     queue.remove_from_queue()
     self.assertEqual('wall 13', queue.get_elements())
Beispiel #3
0
 def test_can_remove_from_queue_second(self):
     queue = Queue()
     queue.add_to_queue(123)
     queue.add_to_queue(456)
     queue.add_to_queue(789)
     queue.remove_from_queue()
     self.assertEqual('789 456', queue.get_elements())
Beispiel #4
0
 def test_can_remove_from_queue_first(self):
     queue = Queue()
     queue.add_to_queue('one')
     queue.add_to_queue('two')
     queue.add_to_queue('three')
     queue.remove_from_queue()
     self.assertEqual('three two', queue.get_elements())
Beispiel #5
0
 def test_can_remove_empty_from_queue(self):
     queue = Queue()
     queue.remove_from_queue()
     self.assertEqual('', queue.get_elements())
Beispiel #6
0
 def test_can_add_empty_to_queue(self):
     queue = Queue()
     queue.add_to_queue('1')
     queue.add_to_queue('1')
     self.assertEqual('1', queue.get_elements())
Beispiel #7
0
 def test_can_add_to_queue_third(self):
     queue = Queue()
     queue.add_to_queue('a')
     queue.add_to_queue('b')
     self.assertEqual('b a', queue.get_elements())
Beispiel #8
0
 def test_can_add_to_queue_second(self):
     queue = Queue()
     queue.add_to_queue('worker')
     queue.add_to_queue('student')
     self.assertEqual('student worker', queue.get_elements())
Beispiel #9
0
 def test_can_add_to_queue_first(self):
     queue = Queue()
     queue.add_to_queue(1)
     queue.add_to_queue(2)
     self.assertEqual('2 1', queue.get_elements())