# Path: pipeline/archivebot/control.py
# def candidate_queues(named_queues, pipeline_nick, ao_only, large):
#     '''
#     Generates names of queues that this pipeline will check for work.
#     '''
# 
#     def applies(q):
#         return q.replace('pending:', '') in pipeline_nick
# 
#     if ao_only and large:
#         return ['pending-ao', 'pending-large']
#     elif ao_only:
#         return ['pending-ao']
#     else:
#         matches = [q for q in named_queues if applies(q)]
#         if large:
#             matches.append('pending-large')
#         matches.append('pending')
#         matches.append('pending-ao')
# 
#         return matches


import unittest
from .control import candidate_queues


class TestCandidateQueues(unittest.TestCase):
    def setUp(self):
        self.named_queues = set([
            'pending:internetcentrum',
            'pending:reddit-over18',
            'pending:ovhca1-47'
        ])

    def test_selects_exact_match_on_nick(self):
        queues = candidate_queues(self.named_queues, 'ovhca1-47', False, large=False)

        self.assertEqual(set(['pending:ovhca1-47', 'pending-ao', 'pending']), set(queues))

    def test_selects_substring_match_on_nick(self):

# Path: pipeline/archivebot/control.py
# def candidate_queues(named_queues, pipeline_nick, ao_only, large):
#     '''
#     Generates names of queues that this pipeline will check for work.
#     '''
# 
#     def applies(q):
#         return q.replace('pending:', '') in pipeline_nick
# 
#     if ao_only and large:
#         return ['pending-ao', 'pending-large']
#     elif ao_only:
#         return ['pending-ao']
#     else:
#         matches = [q for q in named_queues if applies(q)]
#         if large:
#             matches.append('pending-large')
#         matches.append('pending')
#         matches.append('pending-ao')
# 
#         return matches


# Path: pipeline/archivebot/control_test.py
import unittest
from .control import candidate_queues



class TestCandidateQueues(unittest.TestCase):
    def setUp(self):
        self.named_queues = set([
            'pending:internetcentrum',
            'pending:reddit-over18',
            'pending:ovhca1-47'
        ])

    def test_selects_exact_match_on_nick(self):
        queues = candidate_queues(self.named_queues, 'ovhca1-47', False, large=False)

        self.assertEqual(set(['pending:ovhca1-47', 'pending-ao', 'pending']), set(queues))

    def test_selects_substring_match_on_nick(self):

        queues = candidate_queues(self.named_queues, 'ovhca1-reddit-over18-55', False, large=False)