# Path: invtool/main.py
# def do_dispatch(args, IN=sys.stdin):
# def main(args):
# 
# Path: invtool/tests/utils.py
# def call_to_json(command_str):
#     """
#     Given a string, this function will shell out, execute the command
#     and parse the json returned by that command
#     """
#     print command_str
#     p = subprocess.Popen(shlex.split(command_str),
#                          stderr=subprocess.PIPE, stdout=subprocess.PIPE)
#     stdout, stderr = p.communicate()
#     if stderr:
#         return None, stderr, p.returncode
# 
#     stdout = stdout.replace('u\'', '"').replace('\'', '"').strip('\n')
#     try:
#         return json.loads(stdout, 'unicode'), None, p.returncode
#     except json.decoder.JSONDecodeError, e:
#         return (None,
#                 "Ret was: {0}. Got error: {1}".format(stdout, str(e)),
#                 p.returncode)
# 
# def test_method_to_params(test_case):
#     if not test_case:
#         return ''
#     elif not test_case[0]:
#         return test_case[1]
#     else:
#         return "--{0} {1}".format(*test_case)
# 
# EXEC = "./inv --json"


import unittest
import sys
from gettext import gettext as _
from invtool.main import registrar
from invtool.tests.utils import call_to_json, test_method_to_params, EXEC
                self.assertEqual(1, rc)

                self.assertTrue('http_status' in ret)
                self.assertEqual(ret['http_status'], 404)
                self.assertFalse('kv_pk' in ret)

            delete_kv()

        test_name = "test_{0}".format(dispatch.dtype)
        place_holder.__name__ = test_name
        setattr(_TestCase, test_name, place_holder)
        return _TestCase

    def build_testcases(dispatch):
        commands = []
        command = [EXEC, dispatch.dtype, 'create']
        for add_arg, extract_arg, test_method in dispatch.create_args:
            command.append(test_method_to_params(test_method()))
        commands.append((201, ' '.join(command)))

        command = [EXEC, dispatch.dtype, 'update']
        for add_arg, extract_arg, test_method in dispatch.update_args:
            command.append(test_method_to_params(test_method()))
        commands.append((202, ' '.join(command)))

        return build_testcase(dispatch, commands)

    unittest.TestSuite()
    test_cases = []
    # Build KV test cases

# Path: invtool/main.py
# def do_dispatch(args, IN=sys.stdin):
# def main(args):
# 
# Path: invtool/tests/utils.py
# def call_to_json(command_str):
#     """
#     Given a string, this function will shell out, execute the command
#     and parse the json returned by that command
#     """
#     print command_str
#     p = subprocess.Popen(shlex.split(command_str),
#                          stderr=subprocess.PIPE, stdout=subprocess.PIPE)
#     stdout, stderr = p.communicate()
#     if stderr:
#         return None, stderr, p.returncode
# 
#     stdout = stdout.replace('u\'', '"').replace('\'', '"').strip('\n')
#     try:
#         return json.loads(stdout, 'unicode'), None, p.returncode
#     except json.decoder.JSONDecodeError, e:
#         return (None,
#                 "Ret was: {0}. Got error: {1}".format(stdout, str(e)),
#                 p.returncode)
# 
# def test_method_to_params(test_case):
#     if not test_case:
#         return ''
#     elif not test_case[0]:
#         return test_case[1]
#     else:
#         return "--{0} {1}".format(*test_case)
# 
# EXEC = "./inv --json"


# Path: invtool/tests/kv_tests.py
import unittest
import sys
from gettext import gettext as _
from invtool.main import registrar
from invtool.tests.utils import call_to_json, test_method_to_params, EXEC

                self.assertEqual(1, rc)

                self.assertTrue('http_status' in ret)
                self.assertEqual(ret['http_status'], 404)
                self.assertFalse('kv_pk' in ret)

            delete_kv()

        test_name = "test_{0}".format(dispatch.dtype)
        place_holder.__name__ = test_name
        setattr(_TestCase, test_name, place_holder)
        return _TestCase

    def build_testcases(dispatch):
        commands = []
        command = [EXEC, dispatch.dtype, 'create']
        for add_arg, extract_arg, test_method in dispatch.create_args:
            command.append(test_method_to_params(test_method()))
        commands.append((201, ' '.join(command)))

        command = [EXEC, dispatch.dtype, 'update']
        for add_arg, extract_arg, test_method in dispatch.update_args:
            command.append(test_method_to_params(test_method()))
        commands.append((202, ' '.join(command)))

        return build_testcase(dispatch, commands)

    unittest.TestSuite()
    test_cases = []
    # Build KV test cases

    for dispatch in registrar.dispatches: