# Path: caravan/tests/util.py
# def mock_args(args):
#     return mock.patch('sys.argv', ['PROG'] + args)
# 
# Path: caravan/commands/signal.py
# class Command(BaseCommand):
# 
#     description = 'Signal 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('-s', '--signal', required=True)
#         parser.add_argument(
#             '--input',
#             help='Raw input data for this signal',
#             metavar='"<Some data>"')
# 
#     def run(self):
#         run_swf_command(
#             'signal_workflow_execution',
#             domain=self.args.domain,
#             workflowId=self.args.id,
#             signalName=self.args.signal,
#             runId=self.args.run_id,
#             input=self.args.input,
#             )
#         return 'Signal sent.'


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




class Test(unittest.TestCase):

    @httpretty.activate
    def test_nominal(self):
        args = ['-d', 'DOMAIN', '-i', 'ID', '-s', 'SIG']

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

        with captured(out(), err()) as (stdout, stderr):
            with mock_args(args):
                Command.main()

        request = httpretty.last_request()

# Path: caravan/tests/util.py
# def mock_args(args):
#     return mock.patch('sys.argv', ['PROG'] + args)
# 
# Path: caravan/commands/signal.py
# class Command(BaseCommand):
# 
#     description = 'Signal 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('-s', '--signal', required=True)
#         parser.add_argument(
#             '--input',
#             help='Raw input data for this signal',
#             metavar='"<Some data>"')
# 
#     def run(self):
#         run_swf_command(
#             'signal_workflow_execution',
#             domain=self.args.domain,
#             workflowId=self.args.id,
#             signalName=self.args.signal,
#             runId=self.args.run_id,
#             input=self.args.input,
#             )
#         return 'Signal sent.'


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





class Test(unittest.TestCase):

    @httpretty.activate
    def test_nominal(self):
        args = ['-d', 'DOMAIN', '-i', 'ID', '-s', 'SIG']

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

        with captured(out(), err()) as (stdout, stderr):
            with mock_args(args):
                Command.main()

        request = httpretty.last_request()

        self.assertEqual(request.headers.get('x-amz-target'),