_apycotlib/narvalactions.py
author Paul Tonelli <paul.tonelli@logilab.fr>
Mon, 24 Mar 2014 10:17:06 +0100
changeset 1475 2a7c0ab3f126
parent 1458 2c4842747f04
child 1477 c91d4e6d72fd
permissions -rw-r--r--
[apycotlib] improve calls to http_get /post when communicating with cubicweb: - use get to get information from the cubicweb instance - use post to send information to modify the cubicweb instance - do not use object cwuri but concatenate cnxh url with eid

from apycotlib import atest, writer, ERROR

class apycot_environment(object):
    def __init__(self, plan):
        self.plan = plan

    def __enter__(self):
        w  = writer.TestDataWriter(self.plan.cnxh, self.plan.plandata['cwuri'])
        test = atest.Test(self.plan.plandata, w)
        test.setup()
        self.test = test
        return test

    def __exit__(self, exc_type, exc_val, exc_tb):
        if exc_type is not None:
            self.test.global_status = ERROR
        self.test.clean()

def install_environment(test):
    texec_url = test.writer._cnxh.instance_url + str(test.texec['eid'])
    data = test.writer._cnxh.http_get(texec_url, vid='apycot.get_dependencies')
    for dep in data[0]:
        test.checkout(dep)
        test.call_preprocessor('install', dep)