Ejemplo n.º 1
0
    def test_bad_subheader(self):
        expected_message = (
            "The {} section contained an unexpected "
            "subsection name. {} is not a valid subsection"
            " name."
        )
        meta = {
            "build": {"skip": "True", "script": "python setup.py install", "number": 0}
        }
        lints, hints = linter.lintify(meta)
        self.assertNotIn(expected_message.format("build", "ski"), lints)

        meta = {
            "build": {"ski": "True", "script": "python setup.py install", "number": 0}
        }
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message.format("build", "ski"), lints)

        meta = {"source": {"urll": "http://test"}}
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message.format("source", "urll"), lints)

        meta = {"source": [{"urll": "http://test"}, {"url": "https://test"}]}
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message.format("source", "urll"), lints)
Ejemplo n.º 2
0
    def test_maintainers_section(self):
        expected_message = (
            "The recipe could do with some maintainers listed "
            "in the `extra/recipe-maintainers` section."
        )

        lints, hints = linter.lintify({"extra": {"recipe-maintainers": []}})
        self.assertIn(expected_message, lints)

        # No extra section at all.
        lints, hints = linter.lintify({})
        self.assertIn(expected_message, lints)

        lints, hints = linter.lintify({"extra": {"recipe-maintainers": ["a"]}})
        self.assertNotIn(expected_message, lints)

        expected_message = (
            'The "extra" section was expected to be a ' "dictionary, but got a list."
        )
        lints, hints = linter.lintify({"extra": ["recipe-maintainers"]})
        self.assertIn(expected_message, lints)

        lints, hints = linter.lintify({"extra": {"recipe-maintainers": "Luke"}})
        expected_message = "Recipe maintainers should be a json list."
        self.assertIn(expected_message, lints)
Ejemplo n.º 3
0
    def test_test_section(self):
        expected_message = 'The recipe must have some tests.'

        lints = linter.lintify({})
        self.assertIn(expected_message, lints)

        lints = linter.lintify({'test': {'imports': 'sys'}})
        self.assertNotIn(expected_message, lints)
Ejemplo n.º 4
0
    def test_version(self):
        meta = {"package": {"name": "python", "version": "3.6.4"}}
        expected_message = "Package version 3.6.4 doesn't match conda spec"
        lints, hints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)

        meta = {"package": {"name": "python", "version": "2.0.0~alpha0"}}
        expected_message = "Package version 2.0.0~alpha0 doesn't match conda spec"
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message, lints)
Ejemplo n.º 5
0
    def test_maintainers_section(self):
        expected_message = 'The recipe could do with some maintainers listed in the "extra/recipe-maintainers" section.'

        lints = linter.lintify({'extra': {'recipe-maintainers': []}})
        self.assertIn(expected_message, lints)
    
        # No extra section at all.
        lints = linter.lintify({})
        self.assertIn(expected_message, lints)

        lints = linter.lintify({'extra': {'recipe-maintainers': ['a']}})
        self.assertNotIn(expected_message, lints)
Ejemplo n.º 6
0
    def test_missing_build_number(self):
        expected_message = "The recipe must have a `build/number` section."

        meta = {
            "build": {"skip": "True", "script": "python setup.py install", "number": 0}
        }
        lints, hints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)

        meta = {"build": {"skip": "True", "script": "python setup.py install"}}
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message, lints)
Ejemplo n.º 7
0
    def test_missing_build_number(self):
        expected_message = "The recipe must have a `build/number` section."

        meta = {'build': {'skip': 'True',
                          'script': 'python setup.py install',
                          'number': 0}}
        lints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)

        meta = {'build': {'skip': 'True',
                          'script': 'python setup.py install'}}
        lints = linter.lintify(meta)
        self.assertIn(expected_message, lints)
Ejemplo n.º 8
0
    def test_bad_requirements_order(self):
        expected_message = ("The `requirements/build` section should be "
                            "defined before the `requirements/run` section.")

        meta = {'requirements': OrderedDict([['run', 'a'],
                                             ['build', 'a']])}
        lints = linter.lintify(meta)
        self.assertIn(expected_message, lints)

        meta = {'requirements': OrderedDict([['build', 'a'],
                                             ['run', 'a']])}
        lints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)
Ejemplo n.º 9
0
 def test_examples(self):
     msg = "Please move the recipe out of the example dir and into its " "own dir."
     lints, hints = linter.lintify(
         {"extra": {"recipe-maintainers": ["support"]}},
         recipe_dir="recipes/example/",
         conda_forge=True,
     )
     self.assertIn(msg, lints)
     lints = linter.lintify(
         {"extra": {"recipe-maintainers": ["support"]}},
         recipe_dir="python",
         conda_forge=True,
     )
     self.assertNotIn(msg, lints)
Ejemplo n.º 10
0
    def test_test_section_with_recipe(self):
        # If we have a run_test.py file, we shouldn't need to provide
        # other tests.

        expected_message = "The recipe must have some tests."

        with tmp_directory() as recipe_dir:
            lints, hints = linter.lintify({}, recipe_dir)
            self.assertIn(expected_message, lints)

            with io.open(os.path.join(recipe_dir, "run_test.py"), "w") as fh:
                fh.write("# foo")
            lints, hints = linter.lintify({}, recipe_dir)
            self.assertNotIn(expected_message, lints)
Ejemplo n.º 11
0
    def test_no_sha_with_dl(self):
        expected_message = ("When defining a source/url please add a sha256, "
                            "sha1 or md5 checksum (sha256 preferably).")
        meta = {'source': {'url': None}}
        self.assertIn(expected_message, linter.lintify(meta))

        meta = {'source': {'url': None, 'sha1': None}}
        self.assertNotIn(expected_message, linter.lintify(meta))

        meta = {'source': {'url': None, 'sha256': None}}
        self.assertNotIn(expected_message, linter.lintify(meta))

        meta = {'source': {'url': None, 'md5': None}}
        self.assertNotIn(expected_message, linter.lintify(meta))
Ejemplo n.º 12
0
    def test_test_section_with_recipe(self):
        # If we have a run_test.py file, we shouldn't need to provide
        # other tests.

        expected_message = 'The recipe must have some tests.'

        with tmp_directory() as recipe_dir:
            lints = linter.lintify({}, recipe_dir)
            self.assertIn(expected_message, lints)

            with open(os.path.join(recipe_dir, 'run_test.py'), 'w') as fh:
                fh.write('# foo')
            lints = linter.lintify({}, recipe_dir)
            self.assertNotIn(expected_message, lints)
Ejemplo n.º 13
0
    def test_no_sha_with_dl(self):
        expected_message = (
            "When defining a source/url please add a sha256, "
            "sha1 or md5 checksum (sha256 preferably)."
        )
        lints, hints = linter.lintify({"source": {"url": None}})
        self.assertIn(expected_message, lints)

        lints, hints = linter.lintify({"source": {"url": None, "sha1": None}})
        self.assertNotIn(expected_message, lints)

        lints, hints = linter.lintify({"source": {"url": None, "sha256": None}})
        self.assertNotIn(expected_message, lints, hints)

        meta = {"source": {"url": None, "md5": None}}
        self.assertNotIn(expected_message, linter.lintify(meta))
Ejemplo n.º 14
0
 def assert_selector(selector, is_good=True):
     with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh:
         fh.write(
             """
                 package:
                    name: foo_py2  # [py2k]
                    {}
                  """.format(
                 selector
             )
         )
     lints, hints = linter.lintify({}, recipe_dir)
     if is_good:
         message = (
             "Found lints when there shouldn't have been a "
             "lint for '{}'.".format(selector)
         )
     else:
         message = "Expecting lints for '{}', but didn't get any." "".format(
             selector
         )
     self.assertEqual(
         not is_good,
         any(lint.startswith(expected_message) for lint in lints),
         message,
     )
Ejemplo n.º 15
0
    def test_end_empty_line(self):
        bad_contents = [
            # No empty lines at the end of the file
            'extra:\n  recipe-maintainers:\n    - goanpeca',
            'extra:\r  recipe-maintainers:\r    - goanpeca',
            'extra:\r\n  recipe-maintainers:\r\n    - goanpeca',
            # Two empty lines at the end of the file
            'extra:\n  recipe-maintainers:\n    - goanpeca\n\n',
            'extra:\r  recipe-maintainers:\r    - goanpeca\r\r',
            'extra:\r\n  recipe-maintainers:\r\n    - goanpeca\r\n\r\n',
            # Three empty lines at the end of the file
            'extra:\n  recipe-maintainers:\n    - goanpeca\n\n\n',
            'extra:\r  recipe-maintainers:\r    - goanpeca\r\r\r',
            'extra:\r\n  recipe-maintainers:\r\n    - goanpeca\r\n\r\n\r\n',
        ]
        # Exactly one empty line at the end of the file
        valid_content = 'extra:\n  recipe-maintainers:\n    - goanpeca\n'

        for content in bad_contents + [valid_content]:
            with tmp_directory() as recipe_dir:
                with io.open(os.path.join(recipe_dir, 'meta.yaml'), 'w') as f:
                    f.write(content)
                lints = linter.lintify({}, recipe_dir=recipe_dir)
                expected_message = ('There should be one empty line at the '
                                    'end of the file.')
                if content == valid_content:
                    self.assertNotIn(expected_message, lints)
                else:
                    self.assertIn(expected_message, lints)
Ejemplo n.º 16
0
    def test_missing_build_number(self):
        expected_message = "The recipe must have a `build/number` section."

        meta = {
            'build': {
                'skip': 'True',
                'script': 'python setup.py install',
                'number': 0
            }
        }
        lints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)

        meta = {'build': {'skip': 'True', 'script': 'python setup.py install'}}
        lints = linter.lintify(meta)
        self.assertIn(expected_message, lints)
Ejemplo n.º 17
0
 def assert_jinja(jinja_var, is_good=True):
     with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh:
         fh.write(
             """
                  {{% set name = "conda-smithy" %}}
                  {}
                  """.format(
                 jinja_var
             )
         )
     lints, hints = linter.lintify({}, recipe_dir)
     if is_good:
         message = (
             "Found lints when there shouldn't have been a "
             "lint for '{}'.".format(jinja_var)
         )
     else:
         message = (
             "Expecting lints for '{}', but didn't get any."
             "".format(jinja_var)
         )
     self.assertEqual(
         not is_good,
         any(lint.startswith(expected_message) for lint in lints),
         message,
     )
Ejemplo n.º 18
0
 def assert_selector(selector, is_good=True):
     with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh:
         fh.write(
             """
                 package:
                    name: foo_py2  # [py2k]
                    {}
                  """.format(
                 selector
             )
         )
     lints, hints = linter.lintify({}, recipe_dir)
     if is_good:
         message = (
             "Found lints when there shouldn't have been a "
             "lint for '{}'.".format(selector)
         )
     else:
         message = (
             "Expecting lints for '{}', but didn't get any."
             "".format(selector)
         )
     self.assertEqual(
         not is_good,
         any(lint.startswith(expected_message) for lint in lints),
         message,
     )
Ejemplo n.º 19
0
 def assert_jinja(jinja_var, is_good=True):
     with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh:
         fh.write(
             """
                  {{% set name = "conda-smithy" %}}
                  {}
                  """.format(
                 jinja_var
             )
         )
     lints, hints = linter.lintify({}, recipe_dir)
     if is_good:
         message = (
             "Found lints when there shouldn't have been a "
             "lint for '{}'.".format(jinja_var)
         )
     else:
         message = "Expecting lints for '{}', but didn't get any." "".format(
             jinja_var
         )
     self.assertEqual(
         not is_good,
         any(lint.startswith(expected_message) for lint in lints),
         message,
     )
Ejemplo n.º 20
0
    def test_end_empty_line(self):
        bad_contents = [
            # No empty lines at the end of the file
            b'extra:\n  recipe-maintainers:\n    - goanpeca',
            b'extra:\r  recipe-maintainers:\r    - goanpeca',
            b'extra:\r\n  recipe-maintainers:\r\n    - goanpeca',
            # Two empty lines at the end of the file
            b'extra:\n  recipe-maintainers:\n    - goanpeca\n\n',
            b'extra:\r  recipe-maintainers:\r    - goanpeca\r\r',
            b'extra:\r\n  recipe-maintainers:\r\n    - goanpeca\r\n\r\n',
            # Three empty lines at the end of the file
            b'extra:\n  recipe-maintainers:\n    - goanpeca\n\n\n',
            b'extra:\r  recipe-maintainers:\r    - goanpeca\r\r\r',
            b'extra:\r\n  recipe-maintainers:\r\n    - goanpeca\r\n\r\n\r\n',
        ]
        # Exactly one empty line at the end of the file
        valid_content = b'extra:\n  recipe-maintainers:\n    - goanpeca\n'

        for content in bad_contents + [valid_content]:
            with tmp_directory() as recipe_dir:
                with io.open(os.path.join(recipe_dir, 'meta.yaml'), 'wb') as f:
                    f.write(content)
                lints = linter.lintify({}, recipe_dir=recipe_dir)
                expected_message = ('There should be one empty line at the '
                                    'end of the file.')
                if content == valid_content:
                    self.assertNotIn(expected_message, lints)
                else:
                    self.assertIn(expected_message, lints)
Ejemplo n.º 21
0
 def test_bad_order(self):
     meta = OrderedDict([['package', []],
                         ['build', []],
                         ['source', []]])
     lints = linter.lintify(meta)
     expected_message = "The top level meta keys are in an unexpected order. Expecting ['package', 'source', 'build']."
     self.assertIn(expected_message, lints)
Ejemplo n.º 22
0
    def test_missing_build_number(self):
        expected_message = "The recipe must have a `build/number` section."

        meta = {
            "build": {
                "skip": "True",
                "script": "python setup.py install",
                "number": 0,
            }
        }
        lints, hints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)

        meta = {"build": {"skip": "True", "script": "python setup.py install"}}
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message, lints)
Ejemplo n.º 23
0
 def test_recipe_name(self):
     meta = {"package": {"name": "mp++"}}
     lints, hints = linter.lintify(meta)
     expected_message = (
         "Recipe name has invalid characters. only lowercase alpha, "
         "numeric, underscores, hyphens and dots allowed")
     self.assertIn(expected_message, lints)
Ejemplo n.º 24
0
    def test_jinja2_vars(self):
        expected_message = (
            "Jinja2 variable references are suggested to take a ``{{<one space>"
            "<variable name><one space>}}`` form. See lines %s." %
            ([6, 8, 10, 11, 12]))

        with tmp_directory() as recipe_dir:
            with io.open(os.path.join(recipe_dir, "meta.yaml"), "w") as fh:
                fh.write("""
                    package:
                       name: foo
                    requirements:
                      run:
                        - {{name}}
                        - {{ x.update({4:5}) }}
                        - {{ name}}
                        - {{ name }}
                        - {{name|lower}}
                        - {{ name|lower}}
                        - {{name|lower }}
                        - {{ name|lower }}
                    """)

            _, hints = linter.lintify({}, recipe_dir)
            self.assertTrue(any(h.startswith(expected_message) for h in hints))
Ejemplo n.º 25
0
 def test_spdx_license(self):
     msg = (
         "License is not an SPDX identifier (or a custom LicenseRef) nor an SPDX license expression.\n\n"
         "Documentation on acceptable licenses can be found "
         "[here]( https://conda-forge.org/docs/maintainer/adding_pkgs.html#spdx-identifiers-and-expressions )."
     )
     licenses = {
         "BSD-100": False,
         "GPL-2.0": False,
         "GPL-2.0-only": True,
         "Other": False,
         "GPL-2.0-or-later or MIT": True,
         "LGPL-2.0-only | MIT": False,
         "LLVM-exception": False,
         "LicenseRef-kebab-case-2--with.dots OR MIT": True,
         "LicenseRef-HDF5": True,
         "LicenseRef-@HDF5": False,
     }
     for license, good in licenses.items():
         meta = {"about": {"license": license}}
         lints, hints = linter.lintify(meta)
         print(license, good)
         if good:
             self.assertNotIn(msg, hints)
         else:
             self.assertIn(msg, hints)
Ejemplo n.º 26
0
 def test_bad_about_license(self):
     meta = {'about': {'home': 'a URL',
                       'summary': 'A test summary',
                       'license': 'unknown'}}
     lints = linter.lintify(meta)
     expected_message = "The recipe license cannot be unknown."
     self.assertIn(expected_message, lints)
Ejemplo n.º 27
0
 def test_bad_order(self):
     meta = OrderedDict([['package', {}],
                         ['build', {}],
                         ['source', {}]])
     lints = linter.lintify(meta)
     expected_msg = ("The top level meta keys are in an unexpected "
                     "order. Expecting ['package', 'source', 'build'].")
     self.assertIn(expected_msg, lints)
Ejemplo n.º 28
0
 def test_recipe_name(self):
     meta = {"package": {"name": "mp++"}}
     lints, hints = linter.lintify(meta)
     expected_message = (
         "Recipe name has invalid characters. only lowercase alpha, "
         "numeric, underscores, hyphens and dots allowed"
     )
     self.assertIn(expected_message, lints)
Ejemplo n.º 29
0
 def test_redundant_license(self):
     meta = {'about': {'home': 'a URL',
                       'summary': 'A test summary',
                       'license': 'MIT License'}}
     lints = linter.lintify(meta)
     expected_message = ('The recipe `license` should not include '
                         'the word "License".')
     self.assertIn(expected_message, lints)
Ejemplo n.º 30
0
    def test_missing_about_license_and_summary(self):
        meta = {"about": {"home": "a URL"}}
        lints, hints = linter.lintify(meta)
        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 31
0
    def test_missing_about_license_and_summary(self):
        meta = {'about': {'home': 'a URL'}}
        lints = linter.lintify(meta)
        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 32
0
 def test_bad_about_license_family(self):
     meta = {'about': {'home': 'a URL',
                       'summary': 'A test summary',
                       'license': 'BSD 3-clause',
                       'license_family': 'BSD3'}}
     lints = linter.lintify(meta)
     expected = "about/license_family 'BSD3' not allowed"
     self.assertTrue(any(lint.startswith(expected) for lint in lints))
Ejemplo n.º 33
0
    def test_missing_about_license_and_summary(self):
        meta = {'about': {'home': 'a URL'}}
        lints = linter.lintify(meta)
        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 34
0
 def test_string_source(self):
     url = "http://mistake.com/v1.0.tar.gz"
     lints, hints = linter.lintify({"source": url})
     msg = (
         'The "source" section was expected to be a dictionary or a '
         "list, but got a {}.{}."
     ).format(type(url).__module__, type(url).__name__)
     self.assertIn(msg, lints)
Ejemplo n.º 35
0
 def test_bad_order(self):
     meta = OrderedDict([['package', {}],
                         ['build', {}],
                         ['source', {}]])
     lints = linter.lintify(meta)
     expected_msg = ("The top level meta keys are in an unexpected "
                     "order. Expecting ['package', 'source', 'build'].")
     self.assertIn(expected_msg, lints)
Ejemplo n.º 36
0
 def test_examples(self):
     msg = (
         "Please move the recipe out of the example dir and into its "
         "own dir."
     )
     lints, hints = linter.lintify(
         {"extra": {"recipe-maintainers": ["support"]}},
         recipe_dir="recipes/example/",
         conda_forge=True,
     )
     self.assertIn(msg, lints)
     lints = linter.lintify(
         {"extra": {"recipe-maintainers": ["support"]}},
         recipe_dir="python",
         conda_forge=True,
     )
     self.assertNotIn(msg, lints)
Ejemplo n.º 37
0
    def test_missing_about_license_and_summary(self):
        meta = {"about": {"home": "a URL"}}
        lints, hints = linter.lintify(meta)
        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 38
0
 def test_string_source(self):
     url = "http://mistake.com/v1.0.tar.gz"
     lints, hints = linter.lintify({"source": url})
     msg = ('The "source" section was expected to be a dictionary or a '
            "list, but got a {}.{}.").format(
                type(url).__module__,
                type(url).__name__)
     self.assertIn(msg, lints)
Ejemplo n.º 39
0
    def test_maintainers_section(self):
        expected_message = ('The recipe could do with some maintainers listed '
                            'in the `extra/recipe-maintainers` section.')

        lints = linter.lintify({'extra': {'recipe-maintainers': []}})
        self.assertIn(expected_message, lints)

        # No extra section at all.
        lints = linter.lintify({})
        self.assertIn(expected_message, lints)

        lints = linter.lintify({'extra': {'recipe-maintainers': ['a']}})
        self.assertNotIn(expected_message, lints)

        expected_message = ('The "extra" section was expected to be a '
                            'dictionary, but got a list.')
        lints = linter.lintify({'extra': ['recipe-maintainers']})
        self.assertIn(expected_message, lints)
Ejemplo n.º 40
0
    def test_bad_requirements_order(self):
        expected_message = ("The `requirements/build` section should be "
                            "defined before the `requirements/run` section.")

        meta = {'requirements': OrderedDict([['run', 'a'], ['build', 'a']])}
        lints = linter.lintify(meta)
        self.assertIn(expected_message, lints)

        meta = {
            'requirements':
            OrderedDict([['run', 'a'], ['invalid', 'a'], ['build', 'a']])
        }
        lints = linter.lintify(meta)
        self.assertIn(expected_message, lints)

        meta = {'requirements': OrderedDict([['build', 'a'], ['run', 'a']])}
        lints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)
Ejemplo n.º 41
0
    def test_no_sha_with_dl(self):
        expected_message = ("When defining a source/url please add a sha256, "
                            "sha1 or md5 checksum (sha256 preferably).")
        lints, hints = linter.lintify({'source': {'url': None}})
        self.assertIn(expected_message, lints)

        lints, hints = linter.lintify({'source': {'url': None, 'sha1': None}})
        self.assertNotIn(expected_message, lints)

        lints, hints = linter.lintify(
            {'source': {
                'url': None,
                'sha256': None
            }})
        self.assertNotIn(expected_message, lints, hints)

        meta = {'source': {'url': None, 'md5': None}}
        self.assertNotIn(expected_message, linter.lintify(meta))
Ejemplo n.º 42
0
    def test_maintainers_section(self):
        expected_message = ('The recipe could do with some maintainers listed '
                            'in the "extra/recipe-maintainers" section.')

        lints = linter.lintify({'extra': {'recipe-maintainers': []}})
        self.assertIn(expected_message, lints)

        # No extra section at all.
        lints = linter.lintify({})
        self.assertIn(expected_message, lints)

        lints = linter.lintify({'extra': {'recipe-maintainers': ['a']}})
        self.assertNotIn(expected_message, lints)

        expected_message = ('The "extra" section was expected to be a '
                            'dictionary, but got a list.')
        lints = linter.lintify({'extra': ['recipe-maintainers']})
        self.assertIn(expected_message, lints)
Ejemplo n.º 43
0
    def test_no_sha_with_dl(self):
        expected_message = ("When defining a source/url please add a sha256, "
                            "sha1 or md5 checksum (sha256 preferably).")
        lints, hints = linter.lintify({"source": {"url": None}})
        self.assertIn(expected_message, lints)

        lints, hints = linter.lintify({"source": {"url": None, "sha1": None}})
        self.assertNotIn(expected_message, lints)

        lints, hints = linter.lintify(
            {"source": {
                "url": None,
                "sha256": None
            }})
        self.assertNotIn(expected_message, lints, hints)

        meta = {"source": {"url": None, "md5": None}}
        self.assertNotIn(expected_message, linter.lintify(meta))
Ejemplo n.º 44
0
    def test_python_requirements(self):
        meta = {"requirements": {"host": ["python >=3"]}}
        lints, hints = linter.lintify(meta)
        self.assertIn(
            "If python is a host requirement, it should be a run requirement.",
            lints,
        )

        meta = {
            "requirements": {
                "host": ["python >=3"]
            },
            "outputs": [{
                "name": "foo"
            }],
        }
        lints, hints = linter.lintify(meta)
        self.assertNotIn(
            "If python is a host requirement, it should be a run requirement.",
            lints,
        )

        meta = {"requirements": {"host": ["python >=3", "python"]}}
        lints, hints = linter.lintify(meta)
        self.assertNotIn(
            "Non noarch packages should have python requirement without any version constraints.",
            lints,
        )

        meta = {"requirements": {"host": ["python >=3"]}}
        lints, hints = linter.lintify(meta)
        self.assertIn(
            "Non noarch packages should have python requirement without any version constraints.",
            lints,
        )

        meta = {
            "requirements": {
                "host": ["python"],
                "run": ["python-dateutil"]
            }
        }
        # Test that this doesn't crash
        lints, hints = linter.lintify(meta)
Ejemplo n.º 45
0
    def test_bad_requirements_order(self):
        expected_message = (
            'The `requirements/` sections should be defined in '
            'the following order: build, host, run; '
            'instead saw: run, build.')

        meta = {'requirements': OrderedDict([['run', 'a'], ['build', 'a']])}
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message, lints)

        meta = {
            'requirements':
            OrderedDict([['run', 'a'], ['invalid', 'a'], ['build', 'a']])
        }
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message, lints)

        meta = {'requirements': OrderedDict([['build', 'a'], ['run', 'a']])}
        lints, hints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)
Ejemplo n.º 46
0
    def test_missing_about_home_empty(self):
        meta = {"about": {"home": "", "summary": "", "license": ""}}
        lints, hints = linter.lintify(meta)
        expected_message = "The home item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 47
0
 def test_bad_about_license(self):
     meta = {
         'about': {
             'home': 'a URL',
             'summary': 'A test summary',
             'license': 'unknown'
         }
     }
     lints, hints = linter.lintify(meta)
     expected_message = "The recipe license cannot be unknown."
     self.assertIn(expected_message, lints)
Ejemplo n.º 48
0
    def test_missing_about_home_empty(self):
        meta = {"about": {"home": "", "summary": "", "license": ""}}
        lints, hints = linter.lintify(meta)
        expected_message = "The home item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 49
0
 def test_bad_about_license(self):
     meta = {
         "about": {
             "home": "a URL",
             "summary": "A test summary",
             "license": "unknown",
         }
     }
     lints, hints = linter.lintify(meta)
     expected_message = "The recipe license cannot be unknown."
     self.assertIn(expected_message, lints)
Ejemplo n.º 50
0
 def test_bad_about_license(self):
     meta = {
         "about": {
             "home": "a URL",
             "summary": "A test summary",
             "license": "unknown",
         }
     }
     lints, hints = linter.lintify(meta)
     expected_message = "The recipe license cannot be unknown."
     self.assertIn(expected_message, lints)
Ejemplo n.º 51
0
 def test_license_file_required(self):
     meta = {
         "about": {
             "home": "a URL",
             "summary": "A test summary",
             "license": "MIT",
         }
     }
     lints, hints = linter.lintify(meta)
     expected_message = ("license_file entry is missing, but is required.")
     self.assertIn(expected_message, lints)
Ejemplo n.º 52
0
    def test_bad_requirements_order(self):
        expected_message = (
            "The `requirements/` sections should be defined in "
            "the following order: build, host, run; "
            "instead saw: run, build.")

        meta = {"requirements": OrderedDict([["run", "a"], ["build", "a"]])}
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message, lints)

        meta = {
            "requirements":
            OrderedDict([["run", "a"], ["invalid", "a"], ["build", "a"]])
        }
        lints, hints = linter.lintify(meta)
        self.assertIn(expected_message, lints)

        meta = {"requirements": OrderedDict([["build", "a"], ["run", "a"]])}
        lints, hints = linter.lintify(meta)
        self.assertNotIn(expected_message, lints)
Ejemplo n.º 53
0
    def test_missing_about_home_empty(self):
        meta = {'about': {'home': '', 'summary': '', 'license': ''}}
        lints, hints = linter.lintify(meta)
        expected_message = "The home item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 54
0
 def test_bad_about_license_family(self):
     meta = {
         "about": {
             "home": "a URL",
             "summary": "A test summary",
             "license": "BSD 3-clause",
             "license_family": "BSD3",
         }
     }
     lints, hints = linter.lintify(meta)
     expected = "about/license_family 'BSD3' not allowed"
     self.assertTrue(any(lint.startswith(expected) for lint in lints))
Ejemplo n.º 55
0
 def test_redundant_license(self):
     meta = {
         "about": {
             "home": "a URL",
             "summary": "A test summary",
             "license": "MIT License",
         }
     }
     lints, hints = linter.lintify(meta)
     expected_message = ("The recipe `license` should not include "
                         'the word "License".')
     self.assertIn(expected_message, lints)
Ejemplo n.º 56
0
 def test_bad_about_license_family(self):
     meta = {
         "about": {
             "home": "a URL",
             "summary": "A test summary",
             "license": "BSD 3-clause",
             "license_family": "BSD3",
         }
     }
     lints, hints = linter.lintify(meta)
     expected = "about/license_family 'BSD3' not allowed"
     self.assertTrue(any(lint.startswith(expected) for lint in lints))
Ejemplo n.º 57
0
 def test_redundant_license(self):
     meta = {
         'about': {
             'home': 'a URL',
             'summary': 'A test summary',
             'license': 'MIT License'
         }
     }
     lints, hints = linter.lintify(meta)
     expected_message = ('The recipe `license` should not include '
                         'the word "License".')
     self.assertIn(expected_message, lints)
Ejemplo n.º 58
0
 def test_bad_about_license_family(self):
     meta = {
         'about': {
             'home': 'a URL',
             'summary': 'A test summary',
             'license': 'BSD 3-clause',
             'license_family': 'BSD3'
         }
     }
     lints, hints = linter.lintify(meta)
     expected = "about/license_family 'BSD3' not allowed"
     self.assertTrue(any(lint.startswith(expected) for lint in lints))
Ejemplo n.º 59
0
    def test_missing_about_home_empty(self):
        meta = {'about': {'home': '',
                          'summary': '',
                          'license': ''}}
        lints = linter.lintify(meta)
        expected_message = "The home item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The license item is expected in the about section."
        self.assertIn(expected_message, lints)

        expected_message = "The summary item is expected in the about section."
        self.assertIn(expected_message, lints)
Ejemplo n.º 60
0
 def test_license_file_empty(self):
     meta = {
         "about": {
             "home": "a URL",
             "summary": "A test summary",
             "license": "LicenseRef-Something",
             "license_family": "LGPL",
             "license_file": None,
         }
     }
     lints, hints = linter.lintify(meta)
     expected_message = "license_file entry is missing, but is required."
     self.assertIn(expected_message, lints)