#258 Fix tests and python3 support.
Merged 5 months ago by jkaluza. Opened 5 months ago by jkaluza.
jkaluza/odcs fix-tests  into  master

file modified
+3 -3

@@ -23,7 +23,7 @@ 

  import requests

  from collections import defaultdict

  

- import odcs.server.utils

+ from odcs.server.utils import retry, to_text_type

  from odcs.server import log

  

  import gi

@@ -39,7 +39,7 @@ 

      def __init__(self, config):

          self.mbs_url = config.mbs_url.rstrip("/")

  

-     @odcs.server.utils.retry(wait_on=(requests.ConnectionError, ), logger=log)

+     @retry(wait_on=(requests.ConnectionError, ), logger=log)

      def get_modules(self, **params):

          url = self.mbs_url + "/1/module-builds/"

          r = requests.get(url, params=params)

@@ -99,7 +99,7 @@ 

                  mmd.upgrade()

                  for dep in mmd.get_dependencies():

                      dep.add_requires_single(mmd.get_name(), mmd.get_stream())

-                 module["modulemd"] = unicode(mmd.dumps())

+                 module["modulemd"] = to_text_type(mmd.dumps())

              ret.append(module)

          return ret

  

file modified
+1 -1

@@ -197,7 +197,7 @@ 

              # If it is -devel module, there must exist the non-devel

              # counterpart.

              non_devel_nsvc = ":".join([n[:-len("-devel")], s, v, c])

-             if not non_devel_nsvc in source_list:

+             if non_devel_nsvc not in source_list:

                  new_source.append(nsvc)

                  continue

  

@@ -28,10 +28,21 @@ 

  import subprocess

  import shutil

  from threading import Timer

+ from six import text_type

  

  from odcs.server import conf, log

  

  

+ def to_text_type(s):

+     """

+     Converts `s` to `text_type`. In case it fails, returns `s`.

+     """

+     try:

+         return text_type(s, "utf-8")

+     except TypeError:

+         return s

+ 

+ 

  def retry(timeout=conf.net_timeout, interval=conf.net_retry_interval, wait_on=Exception, logger=None):

      """A decorator that allows to retry a section of code until success or timeout."""

      def wrapper(function):