Ejemplo n.º 1
0
    def test_should_properly_parse_get_config_action_with_all_params(self):
        parser = create_argument_parser()
        result = parser.parse_args(
            ['get-config', '--address', '127.0.0.1', '--verbose'])

        self.assertEqual(result.address, '127.0.0.1')
        self.assertTrue(result.verbose)
Ejemplo n.º 2
0
 def test_should_not_parse_template_action_when_only_override_is_given(
         self):
     parser = create_argument_parser()
     with self.assertRaises(SystemExit) as context:
         parser.parse_args(
             ['template', '--address', '127.0.0.1', "--override"])
         self.assertTrue(
             Messages.OVERRIDE_VALID_ONLY_WITH_UPLOAD in context.exception)
Ejemplo n.º 3
0
    def test_should_properly_parse_template_action_with_list_param(self):
        parser = create_argument_parser()
        result = parser.parse_args(
            ['template', '--address', '127.0.0.1', "--list"])

        self.assertTrue(result.list)
        self.assertEqual(result.address, '127.0.0.1')
        self.assertFalse(result.verbose)
Ejemplo n.º 4
0
    def test_should_not_parse_arguments_when_mandatory_params_are_missing_for_event(
            self):
        parser = create_argument_parser()

        with self.assertRaises(SystemExit) as context:
            parser.parse_args(['send', 'event'])
            self.assertTrue(
                'the following arguments are required: --address, --filepath'
                in context.exception)
Ejemplo n.º 5
0
    def test_should_parse_template_action_with_upload_and_override(self):
        parser = create_argument_parser()
        result = parser.parse_args([
            'template', '--address', '127.0.0.1', "--upload",
            "resources/notification.json", "--override"
        ])

        self.assertTrue(result.override)
        self.assertEqual(result.upload, 'resources/notification.json')
Ejemplo n.º 6
0
 def test_should_not_parse_template_action_with_empty_get_content_param(
         self):
     parser = create_argument_parser()
     with self.assertRaises(SystemExit) as context:
         parser.parse_args([
             'template', '--address', '127.0.0.1', "--list", '--get-content'
         ])
         self.assertTrue('argument --get-content: expected one argument' in
                         context.exception)
Ejemplo n.º 7
0
    def test_should_not_parse_arguments_when_mandatory_template_params_are_missing(
            self):
        parser = create_argument_parser()

        with self.assertRaises(SystemExit) as context:
            parser.parse_args(['template'])
            self.assertTrue(
                'one of the arguments --list --get-content is required' in
                context.exception)
Ejemplo n.º 8
0
    def test_should_properly_parse_configure_action_with_all_params(self):
        parser = create_argument_parser()
        result = parser.parse_args([
            'configure', '--address', '127.0.0.1', "--verbose",
            '--ves-server-url', 'sample_url'
        ])

        self.assertEqual(result.address, '127.0.0.1')
        self.assertTrue(result.verbose)
        self.assertEqual(result.ves_server_url, 'sample_url')
Ejemplo n.º 9
0
 def test_should_not_parse_template_action_with_all_params(self):
     parser = create_argument_parser()
     with self.assertRaises(SystemExit) as context:
         parser.parse_args([
             'template', '--address', '127.0.0.1', "--list",
             '--get-content', 'sample'
         ])
         self.assertTrue(
             'argument --get-content: not allowed with argument --list' in
             context.exception)
Ejemplo n.º 10
0
    def test_should_properly_parse_filter_templates_action_with_all_params(
            self):
        parser = create_argument_parser()

        result = parser.parse_args([
            'filter', '--address', '127.0.0.1', '--criteria', '"{}"',
            '--verbose'
        ])

        self.assertEqual(result.address, '127.0.0.1')
        self.assertEqual(result.criteria, "\"{}\"")
        self.assertTrue(result.verbose)
Ejemplo n.º 11
0
    def test_should_properly_parse_send_event_action_with_all_params(self):
        parser = create_argument_parser()

        result = parser.parse_args([
            'send', 'event', '--address', '127.0.0.1', "--filepath",
            'sample_filepath.json', '--verbose', '--ves_server_url',
            'sample_url'
        ])

        self.assertEqual(result.address, '127.0.0.1')
        self.assertEqual(result.filepath, "sample_filepath.json")
        self.assertEqual(result.ves_server_url, 'sample_url')
        self.assertTrue(result.verbose)
Ejemplo n.º 12
0
    def test_should_properly_parse_send_template_action_with_all_params(self):
        parser = create_argument_parser()

        result = parser.parse_args([
            'send', 'template', '--address', '127.0.0.1', "--name",
            'sample_template', '--patch', '"{}"', '--repeats', '2',
            "--interval", '5', '--verbose', '--ves_server_url', 'sample_url'
        ])

        self.assertEqual(result.address, '127.0.0.1')
        self.assertEqual(result.name, "sample_template")
        self.assertEqual(result.patch, "\"{}\"")
        self.assertEqual(result.repeats, 2)
        self.assertEqual(result.interval, 5)
        self.assertEqual(result.ves_server_url, 'sample_url')
        self.assertTrue(result.verbose)