Esempio n. 1
0
 def test_do_not_remove_unknown_options(self):
     arguments=['path', '--foo=8b0', 'create', 'test-dev']
         
     extractor = CommandLineClientOptionsExtractor()
     extractor.extract_and_remove_options_from_arguments(arguments)
     
     self.assertEqual(4, len(arguments), 'option --foo should not have been extracted and removed from list')
Esempio n. 2
0
 def test_port_extraction(self):
     arguments=['path', '--port=8080', 'create', 'test-dev']
     
     extractor = CommandLineClientOptionsExtractor()
     extractor.extract_and_remove_options_from_arguments(arguments)
     
     self.assertEqual(3, len(arguments), 'option --port should have been extracted and removed from list')
     self.assertEqual(8080, extractor.port, 'expected port to be 8080 not %i' % extractor.port)
Esempio n. 3
0
 def test_default_port(self):
     os.environ['YUM_REPO_CLIENT_CONFIG'] = 'src/test/resources/yum-repo-client.yaml'
     arguments=['path', 'create', 'test-dev']
     
     extractor = CommandLineClientOptionsExtractor()
     extractor.extract_and_remove_options_from_arguments(arguments)
     
     self.assertEqual(8123, extractor.port, 'default port should be 8123 not %i' % extractor.port)
Esempio n. 4
0
 def test_default_hostname(self):
     os.environ['YUM_REPO_CLIENT_CONFIG'] = 'src/test/resources/yum-repo-client.yaml'
     arguments=['path', 'create', 'test-dev']
     
     extractor = CommandLineClientOptionsExtractor()
     extractor.extract_and_remove_options_from_arguments(arguments)
     
     self.assertEqual('test-domain.com', extractor.hostname, 'default hostname should be test-domain.com')
Esempio n. 5
0
    def test_use_first_equality_sign_for_key_value_split_and_take_the_rest_as_value(
            self):
        arguments = ['path', '--hostname=any-yum=server', 'create', 'test-dev']

        extractor = CommandLineClientOptionsExtractor()
        extractor.extract_and_remove_options_from_arguments(arguments)
        self.assertEqual(
            'any-yum=server', extractor.hostname,
            'Except the first equality sign, take the rest as value')
Esempio n. 6
0
    def test_ValueError_when_port_is_not_an_int(self):
        arguments = ['path', '--port=8b0', 'create', 'test-dev']

        try:
            extractor = CommandLineClientOptionsExtractor()
            extractor.extract_and_remove_options_from_arguments(arguments)
            self.fail('exception because of wrong argumentFormat not thrown.')
        except OptionParsingException:
            pass
Esempio n. 7
0
 def test_extract_and_remove_options_from_arguments(self):
     
     arguments=['path', '--hostname=any-yum-server.de', 'create', 'test-dev']
     
     extractor = CommandLineClientOptionsExtractor()
     extractor.extract_and_remove_options_from_arguments(arguments)
     
     self.assertEqual(3, len(arguments), 'option --hostname should have been extracted and removed from list')
     self.assertEqual('any-yum-server.de', extractor.hostname, 'extracted hostname %s is not correct.' % extractor.hostname)
Esempio n. 8
0
 def test_option_should_have_an_equality_sign(self):
     arguments=['path', '--hostname', 'any-yum-server', 'create', 'test-dev']
     
     try:
         extractor = CommandLineClientOptionsExtractor()
         extractor.extract_and_remove_options_from_arguments(arguments)
         self.fail('An equality sign is necessary for option/argument assignment.')
     except OptionParsingException:
         pass
 def test_ValueError_when_port_is_not_an_int(self):
     arguments=['path', '--port=8b0', 'create', 'test-dev']
     
     try:        
         extractor = CommandLineClientOptionsExtractor()
         extractor.extract_and_remove_options_from_arguments(arguments)
         self.fail('exception because of wrong argumentFormat not thrown.')
     except OptionParsingException:
         pass
Esempio n. 10
0
    def test_do_not_remove_unknown_options(self):
        arguments = ['path', '--foo=8b0', 'create', 'test-dev']

        extractor = CommandLineClientOptionsExtractor()
        extractor.extract_and_remove_options_from_arguments(arguments)

        self.assertEqual(
            4, len(arguments),
            'option --foo should not have been extracted and removed from list'
        )
Esempio n. 11
0
    def test_default_port(self):
        os.environ[
            'YUM_REPO_CLIENT_CONFIG'] = 'src/test/resources/yum-repo-client.yaml'
        arguments = ['path', 'create', 'test-dev']

        extractor = CommandLineClientOptionsExtractor()
        extractor.extract_and_remove_options_from_arguments(arguments)

        self.assertEqual(8123, extractor.port,
                         'default port should be 8123 not %i' % extractor.port)
Esempio n. 12
0
    def test_default_hostname(self):
        os.environ[
            'YUM_REPO_CLIENT_CONFIG'] = 'src/test/resources/yum-repo-client.yaml'
        arguments = ['path', 'create', 'test-dev']

        extractor = CommandLineClientOptionsExtractor()
        extractor.extract_and_remove_options_from_arguments(arguments)

        self.assertEqual('test-domain.com', extractor.hostname,
                         'default hostname should be test-domain.com')
Esempio n. 13
0
    def test_port_extraction(self):
        arguments = ['path', '--port=8080', 'create', 'test-dev']

        extractor = CommandLineClientOptionsExtractor()
        extractor.extract_and_remove_options_from_arguments(arguments)

        self.assertEqual(
            3, len(arguments),
            'option --port should have been extracted and removed from list')
        self.assertEqual(8080, extractor.port,
                         'expected port to be 8080 not %i' % extractor.port)
Esempio n. 14
0
    def test_option_should_have_an_equality_sign(self):
        arguments = [
            'path', '--hostname', 'any-yum-server', 'create', 'test-dev'
        ]

        try:
            extractor = CommandLineClientOptionsExtractor()
            extractor.extract_and_remove_options_from_arguments(arguments)
            self.fail(
                'An equality sign is necessary for option/argument assignment.'
            )
        except OptionParsingException:
            pass
Esempio n. 15
0
    def test_extract_and_remove_options_from_arguments(self):

        arguments = [
            'path', '--hostname=any-yum-server.de', 'create', 'test-dev'
        ]

        extractor = CommandLineClientOptionsExtractor()
        extractor.extract_and_remove_options_from_arguments(arguments)

        self.assertEqual(
            3, len(arguments),
            'option --hostname should have been extracted and removed from list'
        )
        self.assertEqual(
            'any-yum-server.de', extractor.hostname,
            'extracted hostname %s is not correct.' % extractor.hostname)
Esempio n. 16
0
 def test_use_first_equality_sign_for_key_value_split_and_take_the_rest_as_value(self):
     arguments=['path', '--hostname=any-yum=server', 'create', 'test-dev']
     
     extractor = CommandLineClientOptionsExtractor()
     extractor.extract_and_remove_options_from_arguments(arguments)
     self.assertEqual('any-yum=server', extractor.hostname, 'Except the first equality sign, take the rest as value')