CORD-3049 Unit Tests for SimpleExampleService model policy
Change-Id: Id670827f4141edf4513e2355fec838fa5092de34
diff --git a/xos/synchronizer/model_policies/model_policy_simpleexampleserviceinstance.py b/xos/synchronizer/model_policies/model_policy_simpleexampleserviceinstance.py
index 8cfea04..63db3ef 100644
--- a/xos/synchronizer/model_policies/model_policy_simpleexampleserviceinstance.py
+++ b/xos/synchronizer/model_policies/model_policy_simpleexampleserviceinstance.py
@@ -49,7 +49,8 @@
"url": image.url})
fields["images"] = images
- template = jinja2.Template(open("model_policies/index.html.j2").read())
+ template_fn = os.path.join(os.path.abspath(os.path.dirname(os.path.realpath(__file__))), "index.html.j2")
+ template = jinja2.Template(open(template_fn).read())
return template.render(fields)
@@ -101,9 +102,9 @@
compute_instance = service_instance.compute_instance
mnt = compute_instance.leaf_model.kubernetes_config_volume_mounts.first()
config = mnt.config
- new_data = {"index.html": self.render_index(service_instance)}
+ new_data = json.dumps({"index.html": self.render_index(service_instance)})
if (new_data != config.data):
- config.data = json.dumps(new_data)
+ config.data = new_data
config.save(always_update_timestamp=True)
# Force the Kubernetes syncstep
compute_instance.save(always_update_timestamp=True)