#13 tests: convert to python3
Merged 4 years ago by kparal. Opened 4 years ago by kparal.

file modified
+7 -3
@@ -10,8 +10,12 @@ 

  Running locally

  ===============

  

- You can run the same task locally by running the ansible playbook. Execute the

- following command as root (don't do this on a production machine!)::

+ You can run the same task locally by running the ansible playbook. Install

+ rpmdeplint first::

+ 

+   $ sudo dnf install rpmdeplint

+ 

+ Then execute the following command as root (don't do this on a production machine!)::

  

    $ ansible-playbook tests.yml -e taskotron_item=<koji_tag> -e taskotron_arch=<arch>

  
@@ -38,7 +42,7 @@ 

  

  Install dependepcies::

  

-   sudo dnf install python-virtualenv python2-rpmfluff createrepo_c

+   sudo dnf install rpmdeplint python3-virtualenv python3-rpm createrepo_c

  

  Create virtualenv::

  

file modified
+1 -3
@@ -1,10 +1,8 @@ 

  # This is a list of pypi packages to be installed into virtualenv. Alternatively,

  # you can install these as RPMs instead of pypi packages.

  

- rpmdeplint

- 

  # Test suite requirements

- dingus

  pytest

  pytest-cov

  PyYAML

+ rpmfluff

@@ -55,8 +55,8 @@ 

      # decode the input tuple for readability

      scenario_pass = scenario[0]

      scenario_path = scenario[1]

-     print scenario_pass

-     print "\n### Running scenario %s" % scenario_path

+     print(scenario_pass)

+     print("\n### Running scenario %s" % scenario_path)

  

      # convert the yaml scenario to fake rpms and repos

      scenario_data = read_yamldata(scenario_path)

file modified
+6 -6
@@ -37,13 +37,13 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

    -

-     envra: moo-0.2-3.fc19.noarch

+     nevra: moo-0.2-3.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      requires: foo

  ```

  
@@ -52,16 +52,16 @@ 

  `current_repo`, and `update_repo` are YAML lists of package descriptions. The `current_repo` describes the state of the 'stable' repository,

  and the `update_repo` the available update.

  

- Each package is represented by `envra`. To describe dependencies, you can add `requires`, `provides`, `conflicts`, and `obsoletes`.

+ Each package is represented by `nevra`. To describe dependencies, you can add `requires`, `provides`, `conflicts`, and `obsoletes`.

  Thus creating descriptions like these:

  ```

  ...

  

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

      requires: libbar.so

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      provides: libbar.so

      conflicts: moo

  

@@ -5,12 +5,12 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      requires: foo == 0.1-1.fc19

  

  update_repo:

    -

-     envra: bar-0.2-1.fc19.noarch

+     nevra: bar-0.2-1.fc19.noarch

      requires: foo == 0.2-1.fc19

@@ -5,11 +5,11 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.i386

+     nevra: foo-0.1-1.fc19.i386

    -

-     envra: foo-0.1-1.fc19.x86_64

+     nevra: foo-0.1-1.fc19.x86_64

  

  update_repo:

    -

-     envra: bar-0.2-1.fc19.x86_64

+     nevra: bar-0.2-1.fc19.x86_64

      requires: foo == 0.2-1.x86_64

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.i386

+     nevra: foo-0.1-1.fc19.i386

  

  update_repo:

    -

-     envra: foo-0.2-1.fc19.x86_64

+     nevra: foo-0.2-1.fc19.x86_64

      requires: bar

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.i386

+     nevra: foo-0.1-1.fc19.i386

  

  update_repo:

    -

-     envra: foo-0.2-1.fc19.x86_64

+     nevra: foo-0.2-1.fc19.x86_64

      requires: libbar.so

@@ -5,14 +5,14 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.x86_64

+     nevra: foo-0.1-1.fc19.x86_64

      provides: cannedunicorn

  

    -

-     envra: bar-0.1-1.fc19.x86_64

+     nevra: bar-0.1-1.fc19.x86_64

      requires: cannedunicorn

  

  update_repo:

    -

-     envra: foo-0.2-1.fc19.x86_64

+     nevra: foo-0.2-1.fc19.x86_64

      obsoletes: foo-0.1-1.fc19.x86_64

@@ -4,12 +4,12 @@ 

  expected_outcome: fail

  

  current_repo:

-   - envra: mojito-1.0-1.fc19.noarch

+   - nevra: mojito-1.0-1.fc19.noarch

      requires: libmint = 1.0

  

-   - envra: libmint-1.0-1.fc19.noarch

+   - nevra: libmint-1.0-1.fc19.noarch

      provides: libmint = 1.0

  

  update_repo:

-   - envra: libmint-2.0-1.fc19.noarch

+   - nevra: libmint-2.0-1.fc19.noarch

      provides: libmint = 2.0

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      requires: foo

@@ -6,10 +6,10 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

      conflicts: bar

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      conflicts: foo

@@ -6,9 +6,9 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

      conflicts: bar

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

@@ -6,9 +6,9 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      conflicts: foo

@@ -10,13 +10,13 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.x86_64

+     nevra: foo-0.1-1.fc19.x86_64

      conflicts: foo-extras(x86-32)

  

  update_repo:

    -

-     envra: foo-0.1-1.fc19.i386

+     nevra: foo-0.1-1.fc19.i386

    -

-     envra: foo-extras-0.1-1.fc19.x86_64

+     nevra: foo-extras-0.1-1.fc19.x86_64

    -

-     envra: foo-extras-0.1-1.fc19.i386

+     nevra: foo-extras-0.1-1.fc19.i386

@@ -5,12 +5,12 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.x86_64

+     nevra: foo-0.1-1.fc19.x86_64

    -

-     envra: foo-0.1-1.fc19.i386

+     nevra: foo-0.1-1.fc19.i386

  

  update_repo:

    -

-     envra: foo-0.2-1.fc19.x86_64

+     nevra: foo-0.2-1.fc19.x86_64

    -

-     envra: foo-0.2-1.fc19.i386

+     nevra: foo-0.2-1.fc19.i386

@@ -6,27 +6,27 @@ 

  current_repo:

  

    -

-     envra: kernel-tools-3.17.1-302.fc21.x86_64

+     nevra: kernel-tools-3.17.1-302.fc21.x86_64

  

    -

-     envra: kernel-tools-libs-3.17.1-302.fc21.x86_64

+     nevra: kernel-tools-libs-3.17.1-302.fc21.x86_64

  

    -

-     envra: kernel-tools-libs-devel-3.17.1-302.fc21.x86_64

-     requires: 

+     nevra: kernel-tools-libs-devel-3.17.1-302.fc21.x86_64

+     requires:

          - kernel-tools = 3.17.1-302.fc21

          - kernel-tools-libs = 3.17.1-302.fc21

  

  update_repo:

  

    -

-     envra: kernel-tools-libs-devel-3.17.1-303.fc21.x86_64

+     nevra: kernel-tools-libs-devel-3.17.1-303.fc21.x86_64

      requires:

          - kernel-tools = 3.17.1-303.fc21

          - kernel-tools-libs = 3.17.1-303.fc21

  

    -

-     envra: kernel-tools-3.17.1-303.fc21.x86_64

+     nevra: kernel-tools-3.17.1-303.fc21.x86_64

  

    -

-     envra: kernel-tools-libs-3.17.1-303.fc21.x86_64

+     nevra: kernel-tools-libs-3.17.1-303.fc21.x86_64

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      recommends: foo

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: bar-0.1-0.fc19.noarch

+     nevra: bar-0.1-0.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      recommends: foo

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: foo-0.1-1.fc19.noarch

+     nevra: foo-0.1-1.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      suggests: foo

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: bar-0.1-0.fc19.noarch

+     nevra: bar-0.1-0.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      suggests: foo

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: baz-0.1-1.fc19.noarch

+     nevra: baz-0.1-1.fc19.noarch

  

  update_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

      supplements: foo

@@ -5,9 +5,9 @@ 

  

  current_repo:

    -

-     envra: bar-0.1-1.fc19.noarch

+     nevra: bar-0.1-1.fc19.noarch

  

  update_repo:

    -

-     envra: baz-0.1-1.fc19.noarch

+     nevra: baz-0.1-1.fc19.noarch

      supplements: foo

@@ -20,46 +20,12 @@ 

  import yaml

  import tempfile

  import rpmfluff

- import rpmUtils.arch

- import rpmUtils.miscutils

  import subprocess

  

+ from libtaskotron.ext.fedora import rpm_utils

  

- __all__ = ['create_repos']

  

- def parseENVRA(envra, fmt = "envra"):

-     """

-     @param envra string to be 'manipulated' - can be standard style rpm filename,

-       envra, envr, nvr

-     @param fmt desired format of the string to be returned. Allowed options are:

-       envra, envr, nvra, nvr, e, n, v, r, a. If arch is not present in envra,

-       'noarch' is returned wherever needed.

-     @returns list of strings based on the specified format; if epoch is requested but not

-       present, it is se to empty string

-     """

-     fmt = fmt.lower()

-     supported_formats = ['envra', 'envr', 'nvra', 'nvr', 'e', 'n', 'v', 'r', 'a']

-     if fmt not in supported_formats:

-         raise ValueError("Format '%s' not in supported formats (%s)" % (fmt, ', '.join(supported_formats)))

- 

-     # prepare envra so it can be used with rpmUtils.miscutils.splitFilename()

-     parts = envra.split('.')

-     if parts[-1].lower() != 'rpm':

-         parts.append('rpm')

-     if parts[-2].lower() not in rpmUtils.arch.arches.keys() + ['noarch', 'src']:

-         parts.insert(-1, 'noarch')

- 

-     # split the filename

-     (n, v, r, e, a) = rpmUtils.miscutils.splitFilename('.'.join(parts))

- 

-     if len(fmt) == 1:

-         return {'e':e, 'n':n, 'v':v, 'r':r, 'a':a}[fmt]

- 

-     return {'envra': (e, n, v, r, a),

-             'envr' : (e, n, v ,r),

-             'nvra' : (n, v, r ,a),

-             'nvr'  : (n, v, r),

-            }[fmt]

+ __all__ = ['create_repos']

  

  class MySimpleRpmBuild(rpmfluff.SimpleRpmBuild):

      """Derivative of SimpleRpmBuild which allows setting output directory"""
@@ -84,7 +50,12 @@ 

      @returns instance of MySimpleRpmBuild

      """

  

-     e,n,v,r,a = parseENVRA(package['envra'])

+     n = rpm_utils.rpmformat(package['nevra'], fmt='n', end_arch=True)

+     e = rpm_utils.rpmformat(package['nevra'], fmt='e', end_arch=True)

+     v = rpm_utils.rpmformat(package['nevra'], fmt='v', end_arch=True)

+     r = rpm_utils.rpmformat(package['nevra'], fmt='r', end_arch=True)

+     a = rpm_utils.rpmformat(package['nevra'], fmt='a', end_arch=True)

+ 

      p = MySimpleRpmBuild(n, v, r, [a], rpmdir)

      p.epoch = e

  
@@ -182,7 +153,7 @@ 

              for root, dirs, files in os.walk(os.path.join(rpmdir, directory, 'RPMS')):

                  for file in [f for f in files if f.endswith('.rpm')]:

                      subprocess.check_call(['cp', os.path.join(root, file), repodir])

-                     print "copied %s to %s" % (file, repodir)

+                     print("copied %s to %s" % (file, repodir))

          # create repo

          subprocess.check_call(['createrepo_c', repodir])

  
@@ -194,7 +165,7 @@ 

      try:

          data = yaml.load(open(sys.argv[1]).read())

      except:

-         print >> sys.stderr, ("\n\nMust supply valid yaml.")

+         print("\n\nMust supply valid yaml.", file=sys.stderr)

          sys.exit(1)

  

      create_repos(data)

@@ -1,4 +1,4 @@ 

- from dingus import Dingus

+ import mock

  

  from utils.squash_results import _squash_rpms_to_builds

  from utils import PASS, FAIL
@@ -14,8 +14,9 @@ 

                  'rpm1': {'result': PASS, 'details': []},

                  'rpm2': {'result': PASS, 'details': ["moo"]},

                  }

-         fake_koji = Dingus(rpms_to_build__returns = [{'nvr': 'nvr1'},

-                                                      {'nvr': 'nvr1'}])

+         fake_koji = mock.Mock()

+         fake_koji.rpms_to_build = mock.Mock(return_value=[{'nvr': 'nvr1'},

+                                                           {'nvr': 'nvr1'}])

          outcome = _squash_rpms_to_builds(run_results, fake_koji)

  

          assert len(outcome.keys()) == 1
@@ -31,9 +32,10 @@ 

                  'rpm2': {'result': FAIL, 'details': ["foo bar"]},

                  'rpm3': {'result': PASS, 'details': ["moo"]},

                  }

-         fake_koji = Dingus(rpms_to_build__returns = [{'nvr': 'nvr1'},

-                                                      {'nvr': 'nvr1'},

-                                                      {'nvr': 'nvr1'}])

+         fake_koji = mock.Mock()

+         fake_koji.rpms_to_build = mock.Mock(return_value=[{'nvr': 'nvr1'},

+                                                           {'nvr': 'nvr1'},

+                                                           {'nvr': 'nvr1'}])

          outcome = _squash_rpms_to_builds(run_results, fake_koji)

  

          assert len(outcome.keys()) == 1

no initial comment

Commit 5143045 fixes this pull-request

Pull-Request has been merged by kparal

4 years ago
Metadata
Changes Summary 25
+7 -3
file changed
README.rst
+1 -3
file changed
requirements.txt
+2 -2
file changed
testing/functest_scenarios.py
+6 -6
file changed
testing/scenarios/README.md
+3 -3
file changed
testing/scenarios/scenarios/fail/01_version.yaml
+3 -3
file changed
testing/scenarios/scenarios/fail/02_multilib.yaml
+2 -2
file changed
testing/scenarios/scenarios/fail/03_package_requires.yaml
+2 -2
file changed
testing/scenarios/scenarios/fail/04_file_requires.yaml
+3 -3
file changed
testing/scenarios/scenarios/known_broken/05_removing_provides.yaml
+3 -3
file changed
testing/scenarios/scenarios/known_broken/06_removing_subpackage.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/01_simple.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/02_conflicts_1.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/03_conflicts_2.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/04_conflicts_3.yaml
+4 -4
file changed
testing/scenarios/scenarios/pass/05_strange_conflict.yaml
+4 -4
file changed
testing/scenarios/scenarios/pass/06_multilib.yaml
+7 -7
file changed
testing/scenarios/scenarios/pass/07_codependencies.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/08_recommends_present.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/09_recommends_not_present.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/10_suggests_present.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/11_suggests_not_present.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/12_supplements_present.yaml
+2 -2
file changed
testing/scenarios/scenarios/pass/13_supplements_not_present.yaml
+10 -39
file changed
testing/scenarios/yaml_to_repos.py
+8 -6
file changed
testing/test_squash_results.py