Example #1
0
    def test_unknown_builder(self):
        data = yaml.load(dedent("""
          source: directory
          path: /path
          build: goofy
          config_file: /path/to/mopack.yml
        """), Loader=SafeLineLoader)
        with self.assertRaisesRegex(MarkedYAMLError,
                                    r'line 4, column 8:\n'
                                    r'    build: goofy\n'
                                    r'           \^$'):
            try_make_package('foo', data, _options=self.make_options())

        data = yaml.load(dedent("""
          source: directory
          path: /path
          build:
            type: goofy
          config_file: /path/to/mopack.yml
        """), Loader=SafeLineLoader)
        with self.assertRaisesRegex(MarkedYAMLError,
                                    r'line 5, column 9:\n'
                                    r'      type: goofy\n'
                                    r'            \^$'):
            try_make_package('foo', data, _options=self.make_options())
Example #2
0
    def test_invalid_keys(self):
        # Missing key
        cfg = {'source': 'directory', 'config_file': '/path/to/mopack.yml'}
        self.assertRaises(TypeError, make_package, 'foo', cfg,
                          _options=self.make_options())
        self.assertRaises(TypeError, try_make_package, 'foo', cfg,
                          _options=self.make_options())
        data = yaml.load(dedent("""
          source: directory
          config_file: /path/to/mopack.yml
        """), Loader=SafeLineLoader)
        with self.assertRaisesRegex(MarkedYAMLError,
                                    r'line 2, column 1:\n'
                                    r'    source: directory\n'
                                    r'    \^$'):
            try_make_package('foo', data, _options=self.make_options())

        # Extra key
        cfg = {'source': 'directory', 'path': '/path', 'unknown': 'blah',
               'config_file': '/path/to/mopack.yml'}
        self.assertRaises(TypeError, make_package, 'foo', cfg,
                          _options=self.make_options())
        self.assertRaises(TypeError, try_make_package, 'foo', cfg,
                          _options=self.make_options())
        data = yaml.load(dedent("""
          source: directory
          path: /path
          unknown: blah
          config_file: /path/to/mopack.yml
        """), Loader=SafeLineLoader)
        with self.assertRaisesRegex(MarkedYAMLError,
                                    r'line 4, column 1:\n'
                                    r'    unknown: blah\n'
                                    r'    \^$'):
            try_make_package('foo', data, _options=self.make_options())
Example #3
0
 def test_unknown_source(self):
     cfg = {'source': 'goofy', 'config_file': '/path/to/mopack.yml'}
     self.assertRaises(FieldError, make_package, 'foo', cfg)
     self.assertRaises(FieldError, try_make_package, 'foo', cfg)
     data = yaml.load('source: goofy', Loader=SafeLineLoader)
     with self.assertRaisesRegex(MarkedYAMLError,
                                 r'line 1, column 9:\n'
                                 r'    source: goofy\n'
                                 r'            \^$'):
         try_make_package('foo', data, _options=self.make_options())
Example #4
0
 def test_invalid_usage_values(self):
     data = yaml.load(dedent("""
       source: apt
       usage:
         type: pkg_config
         path: ..
       config_file: /path/to/mopack.yml
     """), Loader=SafeLineLoader)
     with self.assertRaisesRegex(MarkedYAMLError,
                                 r'line 5, column 9:\n'
                                 r'      path: ..\n'
                                 r'            \^$'):
         try_make_package('foo', data, _options=self.make_options())
Example #5
0
 def test_invalid_builder_values(self):
     data = yaml.load(dedent("""
       source: directory
       path: /path
       build:
         type: bfg9000
         extra_args: 1
       config_file: /path/to/mopack.yml
     """), Loader=SafeLineLoader)
     with self.assertRaisesRegex(MarkedYAMLError,
                                 r'line 6, column 15:\n'
                                 r'      extra_args: 1\n'
                                 r'                  \^$'):
         try_make_package('foo', data, _options=self.make_options())
Example #6
0
 def test_invalid_values(self):
     cfg = {'source': 'tarball', 'path': 'file.tar.gz', 'srcdir': '..',
            'config_file': '/path/to/mopack.yml'}
     self.assertRaises(FieldError, make_package, 'foo', cfg,
                       _options=self.make_options())
     self.assertRaises(FieldError, try_make_package, 'foo', cfg,
                       _options=self.make_options())
     data = yaml.load(dedent("""
       source: tarball
       path: file.tar.gz
       srcdir: ..
       config_file: /path/to/mopack.yml
     """), Loader=SafeLineLoader)
     with self.assertRaisesRegex(MarkedYAMLError,
                                 r'line 4, column 9:\n'
                                 r'    srcdir: ..\n'
                                 r'            \^$'):
         try_make_package('foo', data, _options=self.make_options())
Example #7
0
    def test_unknown_usage(self):
        data = yaml.load(dedent("""
          source: apt
          usage: unknown
          config_file: /path/to/mopack.yml
        """), Loader=SafeLineLoader)
        with self.assertRaisesRegex(MarkedYAMLError,
                                    r'line 3, column 8:\n'
                                    r'    usage: unknown\n'
                                    r'           \^$'):
            try_make_package('foo', data, _options=self.make_options())

        data = yaml.load(dedent("""
          source: apt
          usage:
            type: unknown
          config_file: /path/to/mopack.yml
        """), Loader=SafeLineLoader)
        with self.assertRaisesRegex(MarkedYAMLError,
                                    r'line 4, column 9:\n'
                                    r'      type: unknown\n'
                                    r'            \^$'):
            try_make_package('foo', data, _options=self.make_options())