def test_multiprocessor_when_max_workers_is_None_and_number_of_badges_exists(
            self):
        expected_max_processor = None

        get_all = GetAll(self.company)
        get_all._number_of_badges = 1987
        get_all._multiprocessing_badges()
        self.MockThreadPoolExecutor.assert_called_once_with(
            expected_max_processor)
    def test_multiprocessor_when_max_workers_is_greater_than_badges_but_badges_is_zero(
            self):
        expected_max_processor = 999
        badges = 0
        expected_processor = None

        get_all = GetAll(self.company)
        get_all._max_workers = expected_max_processor
        get_all._number_of_badges = badges
        get_all._multiprocessing_badges()
        self.MockThreadPoolExecutor.assert_called_once_with(expected_processor)
    def test_multiprocessor(self):
        urls = [
            'Url #1',
            'Url #2',
            'Url #3',
        ]

        get_all = GetAll(self.company)
        get_all._urls = urls
        get_all._multiprocessing_badges()
        self.MockThreadPoolExecutor_map.assert_called_once_with(
            get_all._request_urls, get_all._urls)
    def test_multiprocessor_get_badges_ids(self):
        badges_1 = [
            'hello-world',
            'Nikki-93-Micah',
            'what.eVer.123',
        ]
        badges_2 = ['cool', 'I-am-badge']
        pages_with_badges = [badges_1, badges_2]
        expected_badges_id = badges_1 + badges_2

        self.MockThreadPoolExecutor_map.return_value = pages_with_badges

        get_all = GetAll(self.company)
        get_all._multiprocessing_badges()
        self.assertEqual(expected_badges_id, get_all._badges_id)
    def test_multiprocessor_when_max_workers_is_less_than_badges(self):
        urls = [
            '',
            '',
            '',
            '',
            '',
        ]
        expected_workers = 2

        get_all = GetAll(self.company)
        get_all._max_workers = expected_workers
        get_all._urls = urls
        get_all._multiprocessing_badges()
        self.MockThreadPoolExecutor.assert_called_once_with(expected_workers)
    def test_get_number_of_badges_from_the_class_get_all_urls(self):
        expected_badges = 29843

        self.MockGetAllUrls.return_value.get_badges = expected_badges

        get_all = GetAll(self.company)
        get_all._multiprocessing_badges = lambda x: x
        get_all.execute()
        number_of_badges = get_all.get_number_of_badges
        self.assertEqual(expected_badges, number_of_badges)