# -*- coding: utf-8 -*- #!/usr/bin/env python import pytest from apilib.monetary import RMB from common import url_fn def test_setTrafficCardCost(super_manager_client, agent): from apps.web.superadmin.views import setTrafficCardCost url = url_fn(setTrafficCardCost) post = super_manager_client.post_json assert post(url, data={'ids': [str(agent.id)]}).json()['result'] == 0 change_to = 30 assert post(url, data={'ids': [str(agent.id)], 'cost': change_to}).json()['result'] == 1 assert agent.reload().trafficCardCost == RMB(change_to) @pytest.mark.parametrize("role_label", ["dealer", "agent", "manager"]) def test_editFeature(role_label, super_manager_client, dealer, agent, manager): from apps.web.superadmin.views import editAgentFeature from apps.web.superadmin.views import editDealerFeature from apps.web.superadmin.views import editManagerFeature __map = { 'dealer': (dealer, editDealerFeature), 'agent': (agent, editAgentFeature), 'manager': (manager, editManagerFeature) } role, view_fn = __map[role_label] url = url_fn(view_fn) role.update(set__features=[]) test_feature = 'test_editFeature' super_manager_client.post_json(url, {'id': str(role.id), 'featureList': [{'key': test_feature, 'value': True}]}) assert test_feature in role.reload().features role.update(features=[])