annotate tests/utils.py @ 81:65c874b2c78e

Update CHANGES
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 12:28:36 +0200
parents 4a9f23230eba
children
rev   line source
0
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
2 # Description:
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
3 # Main test case class with some utilities
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
4 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
5 # Authors:
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
6 # BenoƮt Allard <benoit.allard@greenbone.net>
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
7 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
8 # Copyright:
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
9 # Copyright (C) 2014 Greenbone Networks GmbH
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
10 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
11 # This program is free software; you can redistribute it and/or
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
12 # modify it under the terms of the GNU General Public License
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
13 # as published by the Free Software Foundation; either version 2
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
14 # of the License, or (at your option) any later version.
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
15 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
16 # This program is distributed in the hope that it will be useful,
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
19 # GNU General Public License for more details.
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
20 #
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
21 # You should have received a copy of the GNU General Public License
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
22 # along with this program; if not, write to the Free Software
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
24
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
25 import unittest
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
26
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
27 from farol import main
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
28 from farol.session import CVRFs
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
29
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
30 class TestCase(unittest.TestCase):
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
31
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
32 def setUp(self):
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
33 main.app.testing = True
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
34 main.app.secret_key = 'test key'
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
35 self.app = main.app.test_client()
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
36
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
37 def createDoc(self, title, type_):
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
38 rv = self.app.post('/new', data=dict(title=title, type=type_), follow_redirects=True)
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
39 self.id = list(CVRFs.keys())[0]
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
40 return rv
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
41
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
42 def _assertIn(self, data, response, coding='utf-8'):
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
43 self.assertIn(data, response.data.decode(coding))
4a9f23230eba Initial Release
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
44

http://farol.wald.intevation.org