Skip to content

Commit

Permalink
Test with experiment called 'c1' to kill one mutant
Browse files Browse the repository at this point in the history
-        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
atodorov committed Dec 24, 2016
1 parent 83475e3 commit b8bff85
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/test_pelican_ab.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ def test_render_the_control_experiment(self):
self.assertTrue('href="/a-sample-page.html"' in sample_output) self.assertTrue('href="/a-sample-page.html"' in sample_output)
self.assertTrue('href="/author/mr-senko.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, WHEN AB_EXPERIMENT is configured,
THEN that particular experiment is rendered THEN that particular experiment is rendered
NOTE: for mutation testing 'c1' < 'control' < 'v1'
""" """
v1 = 'v1' v1 = 'v1'
os.environ[jinja_ab._ENV] = v1 os.environ[jinja_ab._ENV] = v1
Expand All @@ -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/a-sample-page.html"' % v1 in sample_output)
self.assertTrue('href="/%s/author/mr-senko.html"' % v1 in self.assertTrue('href="/%s/author/mr-senko.html"' % v1 in
sample_output) 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)
1 change: 1 addition & 0 deletions tests/themes/simple/templates/article.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<section id="content" class="body"> <section id="content" class="body">
{% experiment control %}This is the control experiment{% endexperiment %} {% experiment control %}This is the control experiment{% endexperiment %}
{% experiment v1 %}This is v1 experiment{% endexperiment %} {% experiment v1 %}This is v1 experiment{% endexperiment %}
{% experiment c1 %}This is c1 experiment{% endexperiment %}
<header> <header>
<h2 class="entry-title"> <h2 class="entry-title">
<a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark" <a href="{{ SITEURL }}/{{ article.url }}" rel="bookmark"
Expand Down

0 comments on commit b8bff85

Please sign in to comment.