[Qa-debsources] [PATCH] Add test for index news, bug #783461
Aaron Delaney
aaron.delaney29 at mail.dcu.ie
Tue Mar 22 06:15:03 UTC 2016
Heya,
Okay, fixed the issues we talked about in IRC and that. It no longer uses
the
testdata.py file, and the test data is loaded in the test itself.
I used git format-patch but not git send email, because mail.dcu.ie is
handled
by Gmail and I can't setup SMTP at the moment because of login redirects. I
don't know how the line cap slipped in anyway.
I think this patch should work anyway. If something is wrong, i've attached
the
file git generated anyway. If something is wrong with _that_: well I'll
need to do
some more digging.
Cheers,
Aaron Delaney
---
debsources/tests/test_webapp.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/debsources/tests/test_webapp.py
b/debsources/tests/test_webapp.py
index ccbf1b4..a022465 100644
--- a/debsources/tests/test_webapp.py
+++ b/debsources/tests/test_webapp.py
@@ -53,6 +53,21 @@ class DebsourcesBaseWebTests(DbTestFixture):
cls.app_wrapper.engine.dispose()
cls.db_teardown_cls()
+ def create_news_file(self, name):
+ """Returns news file contents"""
+ fullpath = os.path.join(self.app_wrapper.app.config["LOCAL_DIR"],
name)
+ # don't overwrite any news files that already exist
+ if os.path.isfile(fullpath):
+ news_string = ""
+ with open(fullpath, 'r') as f:
+ news_string = f.read()
+ return news_string
+ else:
+ news_string = "<ul><li>This item was created in a
test</li></ul>"
+ with open(fullpath, 'w') as f:
+ f.write(news_string)
+ return news_string
+
@attr('webapp')
class DebsourcesTestCase(DebsourcesBaseWebTests, unittest.TestCase):
@@ -556,6 +571,11 @@ class DebsourcesTestCase(DebsourcesBaseWebTests,
unittest.TestCase):
rv = self.app.get('/copyright/')
self.assertEqual(200, rv.status_code)
+ def test_index_help(self):
+ # create_news_file preserves existing news files
+ source_news_data = self.create_news_file('sources_news.html')
+ rv = self.app.get('/')
+ self.assertIn(source_news_data, rv.data)
if __name__ == '__main__':
unittest.main(exit=False)
--
2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/qa-debsources/attachments/20160322/85aaf181/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-test-for-index-news.patch
Type: text/x-patch
Size: 1833 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/qa-debsources/attachments/20160322/85aaf181/attachment.bin>
More information about the Qa-debsources
mailing list