예제 #1
0
 def test_must_print_sample_event_json(self):
     event_json = '{"hello": "world"}'
     self.events_lib_mock.generate_event.return_value = event_json
     s = EventTypeSubCommand(self.events_lib_mock, "hello", event_json)
     event = s.cmd_implementation(self.events_lib_mock, self.service_cmd_name, self.event_type_name, {})
     self.events_lib_mock.generate_event.assert_called_with(self.service_cmd_name, self.event_type_name, {})
     self.assertEqual(event, event_json)
예제 #2
0
 def setUp(self):
     self.service_cmd_name = "myservice"
     self.event_type_name = "myevent"
     self.all_cmds = '{"hello": "world", "hi": "you"}'
     self.events_lib_mock = Mock()
     self.s = EventTypeSubCommand(self.events_lib_mock,
                                  self.service_cmd_name, self.all_cmds)
예제 #3
0
    def setUp(self):
        self.service_cmd_name = "myservice"
        self.event_type_name = "myevent"
        self.all_cmds = '{"hello": "world", "hi": "you"}'
        self.events_lib_mock = Mock()
        self.s = EventTypeSubCommand(self.events_lib_mock, self.service_cmd_name, self.all_cmds)

        # Disable telemetry
        self.old_environ = os.environ.copy()
        os.environ["SAM_CLI_TELEMETRY"] = "0"
예제 #4
0
 def test_subcommand_get_command_return_value(self, click_mock, functools_mock, options_click_mock):
     all_commands = {"hi": {"help": "Generates a hello Event", "tags": {}}}
     command_object_mock = Mock()
     click_mock.Command.return_value = command_object_mock
     option_mock = Mock()
     options_click_mock.Option.return_value = option_mock
     callback_object_mock = Mock()
     functools_mock.partial.return_value = callback_object_mock
     s = EventTypeSubCommand(self.events_lib_mock, "hello", all_commands)
     s.get_command(None, "hi")
     click_mock.Command.assert_called_once_with(
         name="hi", short_help="Generates a hello Event", params=[], callback=callback_object_mock,
     )
예제 #5
0
 def test_subcommand_list_return_value(self):
     subcmd_def = {"hello": "world", "hi": "you"}
     self.events_lib_mock.expose_event_metadata.return_value = subcmd_def
     s = EventTypeSubCommand(self.events_lib_mock, "hello", subcmd_def)
     expected = ["hello", "hi"]
     self.assertEqual(s.list_commands(ctx=None), expected)
예제 #6
0
 def test_subcommand_get_accepts_cmd_name_returns_none(self):
     subcmd_definition = '{"hello": { "tags : { "world" }}}'
     s = EventTypeSubCommand(self.events_lib_mock, self.service_cmd_name,
                             subcmd_definition)
     e = s.get_command(None, "heyyo")
     self.assertIsNone(e)
예제 #7
0
 def test_subcommand_accepts_events_lib(self):
     events_lib = Mock()
     events_lib.expose_event_metadata.return_value = self.all_cmds
     s = EventTypeSubCommand(events_lib, self.service_cmd_name,
                             self.all_cmds)
     self.assertEqual(s.events_lib, events_lib)