From 665d2ecdff976915a4f2864623d5546d41db7a4c Mon Sep 17 00:00:00 2001 From: Lars Alexander Blumberg Date: Mon, 14 Aug 2017 10:39:00 +0200 Subject: Add functional test for css file Static files were introduced in this tutorial step. As the tutorials emphasise to write tests, this commits adds a test for the static file `app.css` that was introduced with this tutorial step. --- docs/quick_tutorial/static_assets/tutorial/tests.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/quick_tutorial/static_assets/tutorial/tests.py b/docs/quick_tutorial/static_assets/tutorial/tests.py index 4381235ec..b560ddf82 100644 --- a/docs/quick_tutorial/static_assets/tutorial/tests.py +++ b/docs/quick_tutorial/static_assets/tutorial/tests.py @@ -42,3 +42,7 @@ class TutorialFunctionalTests(unittest.TestCase): def test_hello(self): res = self.testapp.get('/howdy', status=200) self.assertIn(b'

Hi Hello View', res.body) + + def test_css(self): + res = self.testapp.get('/static/app.css', status=200) + self.assertIn(b'body', res.body) -- cgit v1.2.3 From acc4058e231f3e03a32b17f923c0d5b163c63b03 Mon Sep 17 00:00:00 2001 From: Lars Alexander Blumberg Date: Mon, 14 Aug 2017 10:43:01 +0200 Subject: Add a functional test for the static file --- docs/quick_tutorial/static_assets.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/quick_tutorial/static_assets.rst b/docs/quick_tutorial/static_assets.rst index b8482492d..3235f8561 100644 --- a/docs/quick_tutorial/static_assets.rst +++ b/docs/quick_tutorial/static_assets.rst @@ -43,13 +43,18 @@ Steps .. literalinclude:: static_assets/tutorial/static/app.css :language: css -#. Make sure we haven't broken any existing code by running the tests: +#. We add a functional test that asserts that the newly added static file is delivered: + + .. literalinclude:: static_assets/tutorial/tests.py + :linenos: + +#. Now run the tests: .. code-block:: bash $ $VENV/bin/py.test tutorial/tests.py -q .... - 4 passed in 0.50 seconds + 5 passed in 0.50 seconds #. Run your Pyramid application with: -- cgit v1.2.3 From c6ede2dbca90b4fa752a9dfe35dbb1325e522498 Mon Sep 17 00:00:00 2001 From: Lars Alexander Blumberg Date: Tue, 15 Aug 2017 09:43:42 +0200 Subject: Only include test code snippet that has been added --- docs/quick_tutorial/static_assets.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/quick_tutorial/static_assets.rst b/docs/quick_tutorial/static_assets.rst index 3235f8561..81a01061a 100644 --- a/docs/quick_tutorial/static_assets.rst +++ b/docs/quick_tutorial/static_assets.rst @@ -46,7 +46,9 @@ Steps #. We add a functional test that asserts that the newly added static file is delivered: .. literalinclude:: static_assets/tutorial/tests.py - :linenos: + :language: python + :pyobject: TutorialFunctionalTests.test_css + :lineno-match: #. Now run the tests: -- cgit v1.2.3