def test_not_load_save(self):
     conf_ori = utils.Configuration()
     conf = utils.Configuration()
     conf.proxy = 'TestCase %d' % random.randint(0, 100)
     conf.url = 'TestCase %d' % random.randint(0, 100)
     conf.save()
     conf_new = utils.Configuration()
     conf_ori.save()
     self.assertEquals(conf.proxy, conf_new.proxy)
     self.assertEquals(conf.url, conf_new.url)
     self.assertNotEqual(conf_ori.url, conf_new.url)
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
from __future__ import absolute_import, division, print_function

import os
import sys

package_root = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
sys.path.insert(0, package_root)

from cnpsdk import utils

version = utils.Configuration().VERSION
xsd_name = 'chargeback-api-v%s.xsd' % version

# xsd_name = 'chargeback-api-v2.xsd'
print('Generate module fields using pyxb')
xsd_abs_path =  os.path.join(package_root, "schema", xsd_name)
os.system('pyxbgen -u %s -m fields_chargeback' % xsd_abs_path)

print('Copy fields_chargeback.py to package')
gen_field_py_abs_path = os.path.join(package_root, 'tools', 'fields_chargeback.py')
target_field_py_abs_path = os.path.join(package_root, 'cnpsdk', 'fields_chargeback.py')
os.system('mv %s %s' % (gen_field_py_abs_path, target_field_py_abs_path))



# OTHER DEALINGS IN THE SOFTWARE.

import os
import sys
import unittest
from collections import OrderedDict

import mock
import unittest2

from cnpsdk import (utils, chargeback_update)

package_root = os.path.dirname(
    os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
sys.path.insert(0, package_root)
conf = utils.Configuration()


class TestChargebackUpdate(unittest2.TestCase):
    @mock.patch('cnpsdk.communication.http_put_request')
    def test_assign_case_to_user(self, mock_http_put_request):
        mock_http_put_request.return_value = OrderedDict([
            (u'@xmlns', u'http://www.vantivcnp.com/chargebacks'),
            (u'transactionId', u'21260530003675')
        ])
        response = chargeback_update.assign_case_to_user(
            123, "test_user", "test_note")
        args = mock_http_put_request.call_args
        expected_request_body = '<?xml version="1.0" encoding="utf-8"?><chargebackUpdateRequest xmlns="http://www.vantivcnp.com/chargebacks"><activityType>ASSIGN_TO_USER</activityType><assignedTo>test_user</assignedTo><note>test_note</note></chargebackUpdateRequest>'
        request_body = utils.obj_to_xml(args[0][1])
        self.assertEquals(args[0][0], "/chargebacks/123")
def ask_user():
    attrs = [
        'username', 'password', 'merchant_id', 'url', 'proxy', 'print_xml',
        'neuter_xml'
    ]
    attr_dict = {
        'username': '',
        'password': '',
        'merchant_id': '',
        'url': '',
        'proxy': '',
        'print_xml': 'n',
        'neuter_xml': 'n'
    }
    attr_valid_dict = {
        'neuter_xml': {
            'y': True,
            'n': False,
        },
        'print_xml': {
            'y': True,
            'n': False,
        }
    }
    attr_des_dict = {
        'username':
        '******',
        'password':
        '******',
        'merchant_id':
        'Your merchant_id:',
        'url':
        'URL for you online request',
        'proxy':
        'If you want to using https proxy, please input your proxy server address. Must start with "https://"',
        'print_xml':
        'Do you want to print xml in console? y for Yes, n for No.',
        'neuter_xml':
        'Do you want to hide sensitive data in printed xml? y for Yes, n for No.'
    }
    print(CC.bpurple('Vantiv eCommerce Chargeback SDK configuration!'))
    print('''
Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).''')

    for attr in attrs:
        while True:
            print(gene_prompt(attr, attr_dict, attr_valid_dict, attr_des_dict))
            if six.PY3:
                x = input('')
            else:
                x = raw_input('')
            if not x:
                x = attr_dict[attr]
            if attr in attr_valid_dict:
                if x.lower() in attr_valid_dict[attr]:
                    x = attr_valid_dict[attr][x.lower()]
                else:
                    print('Invalid input for "%s" = "%s"' % (attr, x))
                    continue
            attr_dict[attr] = x
            break

    conf = utils.Configuration()
    for k in attr_dict:
        setattr(conf, k, attr_dict[k])
    print(CC.bgreen('Configurations have saved at: %s ' % conf.save()))
    print(CC.bpurple('Successful!'))