Skip to content

Commit

Permalink
Add rendering test for v1 experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed May 10, 2016
1 parent 2b919ac commit 36d0bf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions test.sh
@@ -1,5 +1,5 @@
#!/bin/bash

flake8 pelican_ab/ && \
coverage run --source pelican_ab/ --branch -m unittest discover pelican_ab/tests -v && \
flake8 pelican_ab/ tests/ && \
coverage run --source pelican_ab/ --branch -m unittest discover tests -v && \
coverage report -m
3 changes: 3 additions & 0 deletions tests/pelicanconf.py
Expand Up @@ -47,3 +47,6 @@
CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'

DELETE_OUTPUT_DIRECTORY = False

PLUGIN_PATHS = ['../']
PLUGINS = ['pelican_ab']
12 changes: 6 additions & 6 deletions tests/test_pelican_ab.py
Expand Up @@ -20,8 +20,6 @@
class TestPelicanAB(unittest.TestCase):
def _render(self, run=True):
self.temp_path = mkdtemp(prefix='pelican-ab.')
# pelican_ab_path, _ = os.path.join(os.path.split(pelican_ab.__file__))
# self.pelican_ab_static = os.path.join(pelican_ab_path, 'static')
self.settings = read_settings(path=None,
override={
'PATH': INPUT_PATH,
Expand Down Expand Up @@ -55,7 +53,8 @@ def test_render_the_control_experiment(self):
THEN the control experiment is rendered
"""
self._render()
sample_output = open(os.path.join(self.temp_path, 'a-sample-page.html'), 'r').read()
sample_output = open(os.path.join(self.temp_path,
'a-sample-page.html'), 'r').read()
self.assertTrue('This is the control experiment' in sample_output)
self.assertFalse('This is v1 experiment' in sample_output)

Expand All @@ -64,9 +63,10 @@ def test_render_another_experiment(self):
WHEN AB_EXPERIMENT is configured,
THEN that particular experiment is rendered
"""
os.environ[jinja_ab._ENV] = 'v1'
v1 = 'v1'
os.environ[jinja_ab._ENV] = v1
self._render()
sample_output = open(os.path.join(self.temp_path, 'a-sample-page.html'), 'r').read()
sample_output = open(os.path.join(self.temp_path, v1,
'a-sample-page.html'), 'r').read()
self.assertFalse('This is the control experiment' in sample_output)
self.assertTrue('This is v1 experiment' in sample_output)

0 comments on commit 36d0bf7

Please sign in to comment.