Example #1
0
    def test_required_argument_cannot_follow_an_optional_one(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo)
        self.assertRaisesRegexp(
            Exception, "Cannot add a required argument after an optional one.", definition.add_argument, self.foo2
        )
Example #2
0
    def test_arguments_must_have_different_names(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo)
        self.assertRaisesRegexp(
            Exception, 'An argument with name "foo" already exists.', definition.add_argument, self.foo1
        )
Example #3
0
    def test_argument_count(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo2)
        self.assertEqual(1, definition.get_argument_count())
        definition.add_argument(self.foo)
        self.assertEqual(2, definition.get_argument_count())
Example #4
0
    def test_add_argument(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo)
        self.assertEqual([self.foo], definition.get_arguments())
        definition.add_argument(self.bar)
        self.assertEqual([self.foo, self.bar], definition.get_arguments())
Example #5
0
    def test_add_argument(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo)
        self.assertEqual([self.foo], definition.get_arguments())
        definition.add_argument(self.bar)
        self.assertEqual([self.foo, self.bar], definition.get_arguments())
Example #6
0
    def test_argument_count(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo2)
        self.assertEqual(1, definition.get_argument_count())
        definition.add_argument(self.foo)
        self.assertEqual(2, definition.get_argument_count())
Example #7
0
    def test_required_argument_cannot_follow_an_optional_one(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo)
        self.assertRaisesRegexp(
            Exception, 'Cannot add a required argument after an optional one.',
            definition.add_argument, self.foo2)
Example #8
0
    def test_arguments_must_have_different_names(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(self.foo)
        self.assertRaisesRegexp(Exception,
                                'An argument with name "foo" already exists.',
                                definition.add_argument, self.foo1)
Example #9
0
    def test_list_argument_has_to_be_last(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(InputArgument('foolist',
                                              InputArgument.IS_LIST))
        self.assertRaisesRegexp(
            Exception, 'Cannot add an argument after a list argument.',
            definition.add_argument, InputArgument('anotherbar'))
Example #10
0
    def test_list_argument_has_to_be_last(self):
        self.initialize_arguments()

        definition = InputDefinition()
        definition.add_argument(InputArgument("foolist", InputArgument.IS_LIST))
        self.assertRaisesRegexp(
            Exception,
            "Cannot add an argument after a list argument.",
            definition.add_argument,
            InputArgument("anotherbar"),
        )