示例#1
0
 def test_rotate(self):
     q = Queue()
     for i in range (5):
         q.enqueue(i)
     data = rotate(q, 3)
     res = [3, 4, 0, 1, 2]
     self.assertEqual( (data), res)
示例#2
0
    def test_enqueue_single_element_in_empty_queue(self):
        queue = Queue()
        queue.enqueue(1)

        test_result = queue.queue
        check_result = [1]

        self.assertEqual(
            test_result, check_result,
            "Testing 'Enqueue'. Enqueue single element in empty queue. Result array are not equal."
        )
示例#3
0
 def test_remove(self):
   new_queue = Queue()
   new_queue.add(5)
   new_queue.add(10)
   new_queue.add(20)
   new_queue.remove()
   result = new_queue.return_data()
   self.assertEqual(result, [20, 10])
示例#4
0
    def test_enqueue_single_element_in_ready_queue(self):
        queue = Queue()
        queue.queue = [1, 2]
        queue.enqueue(3)

        test_result = queue.queue
        check_result = [1, 2, 3]

        self.assertEqual(
            test_result, check_result,
            "Testing 'Enqueue'. Enqueue single element in ready queue. Result array are not equal."
        )
示例#5
0
 def test_dequeue(self):
     q = Queue()
     q.enqueue(1)
     q.enqueue(2)
     q.dequeue()
     q.enqueue(3)
     data = q.size()
     res = 2
     self.assertEqual( (data), res)
示例#6
0
 def test_dequeue(self):
     q = Queue()
     q.enqueue(1)
     q.enqueue(2)
     q.dequeue()
     q.enqueue(3)
     data = q.get_data()
     res = [2, 3]
     self.assertEqual( (data), res)
示例#7
0
def load_and_details():
    EnvironmentSetting.set_proxy_mode(2)
    task_manager = TaskManager(Queue())
    task_manager.add_single_keyword_task('28145748', 'TestLoadAndDump2',
                                         'PictureSave', True, False,
                                         UserWorksTask)
    for msg in task_manager.all_task_details():
        print(msg)
示例#8
0
    def test_dequeue_from_empty_queue(self):
        queue = Queue()
        queue.queue = []

        test_value = queue.dequeue()

        test_result = queue.queue
        check_result = []

        self.assertEqual(
            test_result, check_result,
            "Testing 'Dequeue'. Dequeue from empty queue. Result array are not equal."
        )

        self.assertIsNone(
            test_value,
            "Testing 'Dequeue'. Dequeue from normal queue. Dequeued value incorrect."
        )
示例#9
0
  def test_empty(self):
    new_queue = Queue()
    new_queue.add(60)

    result_not_empty = new_queue.is_empty()
    self.assertTrue(result_not_empty)

    new_queue.remove()

    result_empty = new_queue.is_empty()
    self.assertFalse(result_empty)
示例#10
0
    def test_dequeue_from_normal_queue(self):
        queue = Queue()
        queue.queue = [1, 2, 3, 4, 5]

        test_value = queue.dequeue()
        check_value = 1

        test_result = queue.queue
        check_result = [2, 3, 4, 5]

        self.assertEqual(
            test_result, check_result,
            "Testing 'Dequeue'. Dequeue from normal queue. Result array are not equal."
        )

        self.assertEqual(
            test_value, check_value,
            "Testing 'Dequeue'. Dequeue from normal queue. Dequeued value incorrect."
        )
示例#11
0
    def test_enqueue_multiple_elements_in_ready_queue(self):
        queue = Queue()
        queue.queue = [1, 2]
        queue.enqueue(3)
        queue.enqueue(4)
        queue.enqueue(5)

        test_result = queue.queue
        check_result = [1, 2, 3, 4, 5]

        self.assertEqual(
            test_result, check_result,
            "Testing 'Enqueue'. Enqueue multiple elements in ready queue. Result array are not equal."
        )
示例#12
0
def test_queue():
    print('Queue.enqueue() 1, 3, 5, 7')
    queue = Queue()
    queue.enqueue(1)
    queue.enqueue(3)
    queue.enqueue(5)
    queue.enqueue(7)

    print('Queue.dequeue() loop')
    for item in queue:
        print('Item: %s Len: %d' % (item, len(queue)))
示例#13
0
    def test_enqueue_multiple_elements_in_empty_queue(self):
        queue = Queue()
        queue.enqueue(1)
        queue.enqueue(2)
        queue.enqueue(3)

        test_result = queue.queue
        check_result = [1, 2, 3]

        self.assertEqual(
            test_result, check_result,
            "Testing 'Enqueue'. Enqueue multiple elements in empty queue. Result array are not equal."
        )
示例#14
0
def test():
    q = Queue()
    print q.empty()
    print q.peek()
    print q.pop()
    print q.push(1)
    print q.push(2)
    print q.empty()
    print q.peek()
    print q.pop()
示例#15
0
def dump():
    task_manager = TaskManager(Queue())
    task_manager.add_single_keyword_task('26323136', 'TestLoadAndDump1', '.',
                                         True, False, UserWorksTask)
    task_manager._dump_tasks()
    time.sleep(1)
示例#16
0
 def test_dequeue_none(self):
     q = Queue()
     data = q.dequeue()
     res = None
     self.assertEqual( (data), res)
示例#17
0
def main():
    EnvironmentSetting.set_proxy_mode(2)
    task_manager = TaskManager(Queue())
    msg = task_manager.all_task_details()
    print(msg)