Permalink
Browse files

Test with experiment called 'c1' to kill one mutant

-        if (experiment != jinja_ab._ENV_DEFAULT):
+        if (experiment > jinja_ab._ENV_DEFAULT):

is killed by using additional experiment values to test with.
The default is called 'control' and we really need to test with
values which are < 'control' and > 'control' when compared as
strigns!
  • Loading branch information...
1 parent 83475e3 commit b8bff85eeca6c18fbf62cac55fd1a0d64295c43c @atodorov atodorov committed Dec 24, 2016
Showing with 29 additions and 1 deletion.
  1. +28 −1 tests/test_pelican_ab.py
  2. +1 −0 tests/themes/simple/templates/article.html
@@ -65,10 +65,12 @@ def test_render_the_control_experiment(self):
self.assertTrue('href="/a-sample-page.html"' in sample_output)
self.assertTrue('href="/author/mr-senko.html"' in sample_output)
- def test_render_another_experiment(self):
+ def test_render_experiment_v1(self):
"""
WHEN AB_EXPERIMENT is configured,
THEN that particular experiment is rendered
+
+ NOTE: for mutation testing 'c1' < 'control' < 'v1'
"""
v1 = 'v1'
os.environ[jinja_ab._ENV] = v1
@@ -87,3 +89,28 @@ def test_render_another_experiment(self):
self.assertTrue('href="/%s/a-sample-page.html"' % v1 in sample_output)
self.assertTrue('href="/%s/author/mr-senko.html"' % v1 in
sample_output)
+
+ def test_render_experiment_c1(self):
+ """
+ WHEN AB_EXPERIMENT is configured,
+ THEN that particular experiment is rendered
+
+ NOTE: for mutation testing 'c1' < 'control' < 'v1'
+ """
+ c1 = 'c1'
+ os.environ[jinja_ab._ENV] = c1
+
+ self._render()
+ sample_output = open(os.path.join(self.temp_path, c1,
+ 'a-sample-page.html'), 'r').read()
+ # verify correct text is rendered
+ self.assertFalse('This is the control experiment' in sample_output)
+ self.assertTrue('This is c1 experiment' in sample_output)
+ # verify URLs have been changed to point to objects from the experiment
+ # NOTE:
+ # a-simple-page.html is {{ article.url }} aka Content.url
+ # author/mr-senko.html is {{ author.url }} aka URLWrapper.url
+ # both are monkey-patched by this plugin and tested here
+ self.assertTrue('href="/%s/a-sample-page.html"' % c1 in sample_output)
+ self.assertTrue('href="/%s/author/mr-senko.html"' % c1 in
+ sample_output)
@@ -19,6 +19,7 @@
<section id="content" class="body">
{% experiment control %}This is the control experiment{% endexperiment %}
{% experiment v1 %}This is v1 experiment{% endexperiment %}
+{% experiment c1 %}This is c1 experiment{% endexperiment %}
<header>
<h2 class="entry-title">
<a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark"

0 comments on commit b8bff85

Please sign in to comment.