Exemple #1
0
    @transaction()
    def inactivate_user(self, user, curs=None):
        user.is_active = False
        mapping.save(curs, user)

    def check_response_ok(self, resp):
        self.assertEqual('ok', resp['status'])

    @transaction()
    def load_auth_service(self, env_id, curs=None):
        f = ServiceFilter(env_id, {}, {'limit': 1}, ['id'])
        return f.filter_one_obj(curs)

    @transaction()
    def load_service(self, env_id, name, curs=None):
        f = ServiceFilter(env_id, {'name': name}, {}, None)
        return f.filter_one_obj(curs)


def make_api_call(f_name):
    def m(self, **kwargs):
        req_info = RequestInfo(remote_addr='helixauth.test.ip')
        return self.handle_action(f_name, kwargs, req_info)
    m.__name__ = f_name
    return m


methods = get_api_calls(protocol)
for method_name in methods:
    setattr(LogicTestCase, method_name, make_api_call(method_name))
Exemple #2
0
from helixcore.test.utils_for_testing import (ClientSimpleApplication, make_api_call,
    get_api_calls)

from helixtariff.conf.log import logger
from helixtariff.logic.actions import handle_action
from helixtariff.wsgi.protocol import protocol
from helixtariff.wsgi.server import HelixtariffApplication


class Client(ClientSimpleApplication):
    def __init__(self):
        app = HelixtariffApplication(handle_action, protocol, logger)
        super(Client, self).__init__(app)


for method_name in get_api_calls(protocol):
    setattr(Client, method_name, make_api_call(method_name))
Exemple #3
0
from helixcore.test.utils_for_testing import (ClientSimpleApplication,
                                              make_api_call, get_api_calls)

from helixbilling.conf.log import logger
from helixbilling.logic.actions import handle_action
from helixbilling.wsgi.protocol import protocol
from helixbilling.wsgi.application import HelixbillingApplication


class Client(ClientSimpleApplication):
    def __init__(self):
        app = HelixbillingApplication(handle_action, protocol, logger)
        super(Client, self).__init__(app)


for method_name in get_api_calls(protocol):
    setattr(Client, method_name, make_api_call(method_name))
Exemple #4
0
# must be imported first in helixauth set
from helixbilling.test.db_based_test import DbBasedTestCase
from helixbilling.logic import actions
from helixbilling.wsgi.protocol import protocol


class LogicTestCase(DbBasedTestCase):
    def handle_action(self, action, data):
        api = Api(protocol)
        request = dict(data, action=action)
        action_name, data = api.handle_request(json.dumps(request))
        response = actions.handle_action(action_name, dict(data))
        api.handle_response(action_name, dict(response))
        return response

    def check_response_ok(self, resp):
        self.assertEqual('ok', resp['status'])


def make_api_call(f_name):
    def m(self, **kwargs):
        return self.handle_action(f_name, kwargs)

    m.__name__ = f_name
    return m


methods = get_api_calls(protocol)
for method_name in methods:
    setattr(LogicTestCase, method_name, make_api_call(method_name))