# Path: sio/sioworkersd/scheduler/prioritizing.py
# class _WaitingTasksQueue(object):
# class WorkerInfo(object):
# class TaskInfo(object):
# class ContestInfo(object):
# class TasksQueues(object):
# class PrioritizingScheduler(Scheduler):
#     def __init__(self):
#     def __contains__(self, task):
#     def __len__(self):
#     def __nonzero__(self):
#     def add(self, task):
#     def remove(self, task):
#     def left(self):
#     def popleft(self):
#     def getTasksRequiredRam(self):
#     def __init__(self, wid, wdata):
#     def __lt__(self, other):
#     def getQueueName(self):
#     def getAvailableRam(self):
#     def getAvailableVcpuSlots(self):
#     def attachTask(self, task):
#     def detachTask(self, task):
#     def __init__(self, env, contest):
#     def __init__(self, contest_uid, priority, weight):
#     def __init__(self, random):
#     def __nonzero__(self):
#     def addTask(self, task):
#     def delTask(self, task):
#     def chooseTask(self):
#     def __init__(self, manager):
#     def __unicode__(self):
#     def _insertWorkerToQueue(self, worker):
#     def _removeWorkerFromQueue(self, worker):
#     def addWorker(self, worker_id):
#     def delWorker(self, worker_id):
#     def _getAnyCpuQueueSize(self):
#     def _getBestWorkerForVirtualCpuTask(self, queue, task_ram, prefer_busy=False):
#         def suitability(worker):
#     def _getBestVcpuOnlyWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForRealCpuTask(self, task_ram):
#     def updateContest(self, contest_uid, priority, weight):
#     def _addTaskToQueues(self, task):
#     def _removeTaskFromQueues(self, task):
#     def _attachTaskToWorker(self, task, worker):
#     def addTask(self, env):
#     def delTask(self, task_id):
#     def _getNumberOfBlockedAnyCpuWorkers(self):
#     def _scheduleOnce(self):
#     def schedule(self):


import random
import unittest
import six
from sio.sioworkersd.scheduler import prioritizing
from six.moves import range
        s = prioritizing._WaitingTasksQueue()
        task_1 = create_task_info(ram=1024)
        task_2 = create_task_info(ram=256)

        s.add(task_1)
        s.add(task_2)

        self.assertEqual(s.getTasksRequiredRam(), [256, 1024])

    def test_should_update_ram_requirements_when_task_is_removed(self):
        s = prioritizing._WaitingTasksQueue()
        task_1 = create_task_info(ram=1024)
        task_2 = create_task_info(ram=256)

        s.add(task_1)
        s.add(task_2)
        s.remove(task_2)

        self.assertEqual(s.getTasksRequiredRam(), [1024])


class WorkerInfoTest(unittest.TestCase):
    def test_get_queue_name_should_pick_correct_queue(self):
        vcpu_only_worker = create_worker_info(is_real_cpu=False)
        any_cpu_worker = create_worker_info(is_real_cpu=True)

        self.assertEqual(vcpu_only_worker.getQueueName(), 'vcpu-only')
        self.assertEqual(any_cpu_worker.getQueueName(), 'any-cpu')

    def test_get_queue_name_should_return_none_when_worker_is_busy(self):

# Path: sio/sioworkersd/scheduler/prioritizing.py
# class _WaitingTasksQueue(object):
# class WorkerInfo(object):
# class TaskInfo(object):
# class ContestInfo(object):
# class TasksQueues(object):
# class PrioritizingScheduler(Scheduler):
#     def __init__(self):
#     def __contains__(self, task):
#     def __len__(self):
#     def __nonzero__(self):
#     def add(self, task):
#     def remove(self, task):
#     def left(self):
#     def popleft(self):
#     def getTasksRequiredRam(self):
#     def __init__(self, wid, wdata):
#     def __lt__(self, other):
#     def getQueueName(self):
#     def getAvailableRam(self):
#     def getAvailableVcpuSlots(self):
#     def attachTask(self, task):
#     def detachTask(self, task):
#     def __init__(self, env, contest):
#     def __init__(self, contest_uid, priority, weight):
#     def __init__(self, random):
#     def __nonzero__(self):
#     def addTask(self, task):
#     def delTask(self, task):
#     def chooseTask(self):
#     def __init__(self, manager):
#     def __unicode__(self):
#     def _insertWorkerToQueue(self, worker):
#     def _removeWorkerFromQueue(self, worker):
#     def addWorker(self, worker_id):
#     def delWorker(self, worker_id):
#     def _getAnyCpuQueueSize(self):
#     def _getBestWorkerForVirtualCpuTask(self, queue, task_ram, prefer_busy=False):
#         def suitability(worker):
#     def _getBestVcpuOnlyWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForRealCpuTask(self, task_ram):
#     def updateContest(self, contest_uid, priority, weight):
#     def _addTaskToQueues(self, task):
#     def _removeTaskFromQueues(self, task):
#     def _attachTaskToWorker(self, task, worker):
#     def addTask(self, env):
#     def delTask(self, task_id):
#     def _getNumberOfBlockedAnyCpuWorkers(self):
#     def _scheduleOnce(self):
#     def schedule(self):


# Path: sio/sioworkersd/scheduler/test_prioritizing.py
import random
import unittest
import six
from sio.sioworkersd.scheduler import prioritizing
from six.moves import range

        s = prioritizing._WaitingTasksQueue()
        task_1 = create_task_info(ram=1024)
        task_2 = create_task_info(ram=256)

        s.add(task_1)
        s.add(task_2)

        self.assertEqual(s.getTasksRequiredRam(), [256, 1024])

    def test_should_update_ram_requirements_when_task_is_removed(self):
        s = prioritizing._WaitingTasksQueue()
        task_1 = create_task_info(ram=1024)
        task_2 = create_task_info(ram=256)

        s.add(task_1)
        s.add(task_2)
        s.remove(task_2)

        self.assertEqual(s.getTasksRequiredRam(), [1024])


class WorkerInfoTest(unittest.TestCase):
    def test_get_queue_name_should_pick_correct_queue(self):
        vcpu_only_worker = create_worker_info(is_real_cpu=False)
        any_cpu_worker = create_worker_info(is_real_cpu=True)

        self.assertEqual(vcpu_only_worker.getQueueName(), 'vcpu-only')
        self.assertEqual(any_cpu_worker.getQueueName(), 'any-cpu')

    def test_get_queue_name_should_return_none_when_worker_is_busy(self):

        vcpu_only_worker = create_worker_info(concurrency=2, is_real_cpu=False)