Beispiel #1
0
def setup_local_afe():
    """
    Setup a local afe database and return a direct_afe object to access it.

    @returns: A autotest_lib.frontend.afe.direct_afe instance.
    """
    # This import statement is delayed until now rather than running at
    # module load time, because it kicks off a local sqlite :memory: backed
    # database, and we don't need that unless we are doing a local run.
    from autotest_lib.frontend import setup_django_lite_environment
    from autotest_lib.frontend.afe import direct_afe
    return direct_afe.directAFE()
    def testEntryCreation(self):
        afe = direct_afe.directAFE()

        jobs = afe.get_jobs()
        self.assertEquals(len(jobs), 0)

        hosts = afe.get_hosts()
        self.assertEquals(len(hosts), 0)

        afe.create_host('a_host')
        hosts = afe.get_hosts()
        self.assertEquals(len(hosts), 1)

        afe.create_job('job_name', hosts=['a_host'])
        jobs = afe.get_jobs()
        self.assertEquals(len(jobs), 1)