Commit 595ffec2 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

[slapos.cookbook] fix failures in slapos.test.test_recipe.additional_tests

parent 666d846c
......@@ -27,7 +27,7 @@ class PBSTest(unittest.TestCase):
local_dir='TEST_LOCAL_DIR',
remote_dir='TEST_REMOTE_DIR',
rdiff_wrapper_path=rdiff_wrapper.name)
content = rdiff_wrapper.read()
content = open(rdiff_wrapper.name, 'r').read()
self.assertIn('--remote-schema TEST_REMOTE_SCHEMA', content)
self.assertIn('TEST_LOCAL_DIR', content)
self.assertIn('TEST_REMOTE_DIR', content)
......@@ -41,7 +41,7 @@ class PBSTest(unittest.TestCase):
remote_dir='TEST_REMOTE_DIR',
rdiff_wrapper_path=rdiff_wrapper.name,
remove_backup_older_than='TEST_OLDER')
content = rdiff_wrapper.read()
content = open(rdiff_wrapper.name, 'r').read()
self.assertIn('--remote-schema TEST_REMOTE_SCHEMA', content)
self.assertIn('TEST_LOCAL_DIR', content)
self.assertIn('TEST_REMOTE_DIR', content)
......
import os, shutil, tempfile, unittest
from slapos.recipe import promise_plugin
from slapos.test.utils import makeRecipe
from pprint import pformat
import stat, json
class TestPromisePlugin(unittest.TestCase):
......@@ -33,7 +34,7 @@ in multi line
recipe.install()
self.assertTrue(os.path.exists(self.output))
with open(self.output) as f:
with open(self.output, 'r') as f:
content = f.read()
self.assertIn("from slapos.promise.plugin.check_site_available import RunPromise", content)
self.assertEqual(stat.S_IMODE(os.stat(self.output).st_mode), int('644', 8))
......@@ -44,7 +45,7 @@ in multi line
param3=self.options['config-param3'],
param4=self.options['config-param4'],
)
self.assertIn('extra_config_dict = json.loads("""%s""", strict=False)' % json.dumps(expected_dict, indent=2, sort_keys=True), content)
self.assertIn('extra_config_dict = %s' % pformat(expected_dict, indent=2), content)
def test_no_module_set(self):
recipe = makeRecipe(
......@@ -67,7 +68,7 @@ in multi line
with open(self.output) as f:
content = f.read()
self.assertIn("from slapos.promise.plugin.check_site_available import RunPromise", content)
self.assertIn('extra_config_dict = json.loads("""{}""", strict=False)', content)
self.assertIn('extra_config_dict = { }', content)
def test_bad_parameters(self):
......@@ -84,8 +85,8 @@ in multi line
with open(self.output) as f:
content = f.read()
expected_param1 = '"param1; print \\"toto\\"": "#xxxx\\"\\nimport os; os.stat(f)",'
expected_param2 = '"param2\\n@domething": "\\"#$$*PPP\\n\\n p = 2*5; print \\"result is %s\\" % p"'
expected_param1 = r"""'param1; print "toto"': '#xxxx"\nimport os; os.stat(f)',"""
expected_param2 = r"""'param2\n@domething': '"#$$*PPP\n\n p = 2*5; print "result is %s" % p'"""
self.assertIn(expected_param1, content)
self.assertIn(expected_param2, content)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment