コード例 #1
0
    def test_jobboard_iterator_checks_no_capability_if_no_jobs(self):
        ret_func = jobboard_iterator(
            lambda only_unclaimed, ensure_fresh: iter(list()))

        # Return value is lazy. Must consume to trigger
        # side effects. That's what the list() is for
        list(ret_func())

        self.assertFalse(self.has_capability.called)
コード例 #2
0
def jobboard_backend_connection():
    """
    Get a connection to the job board backend and yield the connection
    to the context
    :yield obj conn: The job board backend connection
    """
    persistence_backend = persistence_backends.fetch(PERSISTENCE_CONF)
    job_board_backend = jobboard_backends.fetch(
        CONDUCTOR_NAME, JOBBOARD_CONF, persistence=persistence_backend)
    job_board_backend.connect()
    with closing(job_board_backend) as conn:
        conn.unfiltered_iterjobs = conn.iterjobs
        conn.iterjobs = jobboard_iterator(conn.unfiltered_iterjobs)
        yield conn
コード例 #3
0
    def test_jobboard_iterator_checks_the_capability_of_every_job(self):
        ret_func = jobboard_iterator(fake_iterjobs)

        # Return value is lazy. Must consume to trigger
        # side effects. That's what the list() is for
        list(ret_func())

        expected_calls = (
            call('is_x86_64',
                 jobboard_job=fake_job_with_satisfied_capability_requirements),
            call('is_blabla',
                 jobboard_job=fake_job_with_unsatisfied_capability_requirements
                 ),
            call('is_armv7',
                 jobboard_job=fake_job_with_unsatisfied_capability_requirements
                 ),
            # note that 'is_ubuntu' is short-circuited out by all()
            # if any earlier capability evaluated to False, all remaining
            # capabilities for that job will not be checked.
        )

        self.assertCountEqual(self.has_capability.mock_calls, expected_calls)
コード例 #4
0
    def test_jobboard_iterator_returns_jobs_with_satisfied_capabilities(self):
        ret_func = jobboard_iterator(fake_iterjobs)

        expected_jobs = (fake_job_without_capability_requirements,
                         fake_job_with_satisfied_capability_requirements)
        self.assertCountEqual(ret_func(), expected_jobs)
コード例 #5
0
    def test_jobboard_iterator_uses_lazy_evaluation(self):
        ret_func = jobboard_iterator(fake_iterjobs)

        ret_func()

        self.assertFalse(self.has_capability.called)