# Path: caravan/tests/util.py
# def mock_args(args):
#     return mock.patch('sys.argv', ['PROG'] + args)
# 
# Path: caravan/commands/terminate.py
# class Command(BaseCommand):
# 
#     description = 'Terminate a workflow execution'
# 
#     def setup_arguments(self, parser):
#         parser.add_argument('-d', '--domain', required=True)
#         parser.add_argument('-i', '--id', required=True)
#         parser.add_argument('--run-id')
#         parser.add_argument('--reason')
#         parser.add_argument('--details')
#         parser.add_argument('--child-policy', choices=self.CHILD_POLICIES)
# 
#     def run(self):
#         run_swf_command(
#             'terminate_workflow_execution',
#             domain=self.args.domain,
#             workflowId=self.args.id,
#             runId=self.args.run_id,
#             reason=self.args.reason,
#             details=self.args.details,
#             childPolicy=self.args.child_policy,
#             )
#         return 'Execution terminated.'


import unittest
import json
import httpretty
from abduct import captured, out, err
from caravan.tests.util import mock_args
from caravan.commands.terminate import Command




def httpretty_register():
    headers = {
        'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57',
        }
    body = '{"runId": "1e536162-f1ea-48b0-85f3-aade88eef2f7"}'
    httpretty.register_uri(httpretty.POST,
                           "https://swf.us-east-1.amazonaws.com/",
                           content_type='application/json',
                           adding_headers=headers,
                           body=body)


def run_command(additional_args):
    httpretty_register()

    args = ['-d', 'DOMAIN', '-i', 'ID']
    args += additional_args
    with captured(out(), err()) as (stdout, stderr):

# Path: caravan/tests/util.py
# def mock_args(args):
#     return mock.patch('sys.argv', ['PROG'] + args)
# 
# Path: caravan/commands/terminate.py
# class Command(BaseCommand):
# 
#     description = 'Terminate a workflow execution'
# 
#     def setup_arguments(self, parser):
#         parser.add_argument('-d', '--domain', required=True)
#         parser.add_argument('-i', '--id', required=True)
#         parser.add_argument('--run-id')
#         parser.add_argument('--reason')
#         parser.add_argument('--details')
#         parser.add_argument('--child-policy', choices=self.CHILD_POLICIES)
# 
#     def run(self):
#         run_swf_command(
#             'terminate_workflow_execution',
#             domain=self.args.domain,
#             workflowId=self.args.id,
#             runId=self.args.run_id,
#             reason=self.args.reason,
#             details=self.args.details,
#             childPolicy=self.args.child_policy,
#             )
#         return 'Execution terminated.'


# Path: caravan/tests/commands/test_terminate.py
import unittest
import json
import httpretty
from abduct import captured, out, err
from caravan.tests.util import mock_args
from caravan.commands.terminate import Command





def httpretty_register():
    headers = {
        'x-amzn-RequestId': 'd68969c7-3f0d-11e1-9b11-7182192d0b57',
        }
    body = '{"runId": "1e536162-f1ea-48b0-85f3-aade88eef2f7"}'
    httpretty.register_uri(httpretty.POST,
                           "https://swf.us-east-1.amazonaws.com/",
                           content_type='application/json',
                           adding_headers=headers,
                           body=body)


def run_command(additional_args):
    httpretty_register()

    args = ['-d', 'DOMAIN', '-i', 'ID']
    args += additional_args
    with captured(out(), err()) as (stdout, stderr):

        with mock_args(args):