Fix the handling of modulemd files with unicode characters.

This commit introduces new to_text_type helper method and calls it
for return value of all mmd.dumps() calls. That way, we always
end up with proper unicode string represntation on both python
major versions.

This commit also adds unicode character to description of all
the yaml files we use in the tests so we can be sure MBS can
handle unicode characters properly.

This might be temporary fix, depending on the result of discussion
at https://github.com/fedora-modularity/libmodulemd/issues/184.
This commit is contained in:
Jan Kaluza
2019-02-12 15:57:22 +01:00
committed by mprahl
parent 7052ea0a11
commit 40f23b65e4
37 changed files with 122 additions and 97 deletions

View File

@@ -31,6 +31,7 @@ try:
except ImportError:
import xmlrpc.client as xmlrpclib
from collections import OrderedDict
from module_build_service.utils import to_text_type
import module_build_service.messaging
import module_build_service.scheduler.handlers.repos
@@ -266,7 +267,7 @@ class TestKojiBuilder:
xmd = glib.from_variant_dict(mmd.get_xmd())
xmd["mbs_options"] = {"blocked_packages": ["foo", "bar", "new"]}
mmd.set_xmd(glib.dict_values(xmd))
self.module.modulemd = mmd.dumps()
self.module.modulemd = to_text_type(mmd.dumps())
builder = FakeKojiModuleBuilder(owner=self.module.owner,
module=self.module,
@@ -448,14 +449,14 @@ class TestKojiBuilder:
xmd = glib.from_variant_dict(mmd.get_xmd())
xmd["mbs_options"] = {"blocked_packages": ["foo", "nginx"]}
mmd.set_xmd(glib.dict_values(xmd))
self.module.modulemd = mmd.dumps()
self.module.modulemd = to_text_type(mmd.dumps())
if custom_whitelist:
mmd = self.module.mmd()
opts = mmd.get_buildopts()
opts.set_rpm_whitelist(['custom1', 'custom2'])
mmd.set_buildopts(opts)
self.module.modulemd = mmd.dumps()
self.module.modulemd = to_text_type(mmd.dumps())
if repo_include_all is False:
mmd = self.module.mmd()
@@ -464,7 +465,7 @@ class TestKojiBuilder:
mbs_options["repo_include_all"] = False
xmd["mbs_options"] = mbs_options
mmd.set_xmd(glib.dict_values(xmd))
self.module.modulemd = mmd.dumps()
self.module.modulemd = to_text_type(mmd.dumps())
if override_arches:
mmd = self.module.mmd()
@@ -473,7 +474,7 @@ class TestKojiBuilder:
mbs_options["buildrequires"] = {"platform": {"stream": "xx"}}
xmd["mbs"] = mbs_options
mmd.set_xmd(glib.dict_values(xmd))
self.module.modulemd = mmd.dumps()
self.module.modulemd = to_text_type(mmd.dumps())
builder = FakeKojiModuleBuilder(
owner=self.module.owner, module=self.module, config=conf, tag_name='module-foo',
@@ -532,7 +533,7 @@ class TestKojiBuilder:
xmd = glib.from_variant_dict(mmd.get_xmd())
xmd["mbs_options"] = {"blocked_packages": ["foo", "nginx"]}
mmd.set_xmd(glib.dict_values(xmd))
self.module.modulemd = mmd.dumps()
self.module.modulemd = to_text_type(mmd.dumps())
builder = FakeKojiModuleBuilder(
owner=self.module.owner, module=self.module, config=conf, tag_name='module-foo',

View File

@@ -4,6 +4,7 @@ import koji
import tempfile
import shutil
from textwrap import dedent
from module_build_service.utils import to_text_type
import kobo.rpmlib
@@ -92,7 +93,7 @@ class TestMockModuleBuilder:
name="mbs-testmodule",
stream="test",
version="20171027111452",
modulemd=mmd.dumps(),
modulemd=to_text_type(mmd.dumps()),
scmurl="file:///testdir",
username="test",
)