Erik Grinaker is sharing code with you
Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.
Don't show this againRevelation / test / datahandler.py
- commit
- ac9e3621e5ea
- parent
- 5a85d838a653
- branch
- default
- tags
- revelation-0.4.1
set release date
1 |
52f5c16c80a3
|
#!/usr/bin/env python |
2 |
52f5c16c80a3
|
|
3 |
52f5c16c80a3
|
# |
4 |
653238141312
|
# Revelation 0.4.1 - a password manager for GNOME 2 |
5 |
52f5c16c80a3
|
# http://oss.codepoet.no/revelation/ |
6 |
52f5c16c80a3
|
# $Id$ |
7 |
52f5c16c80a3
|
# |
8 |
52f5c16c80a3
|
# Unit tests for DataHandler module |
9 |
52f5c16c80a3
|
# |
10 |
52f5c16c80a3
|
# |
11 |
07c1fb2b0c27
|
# Copyright (c) 2003-2005 Erik Grinaker |
12 |
52f5c16c80a3
|
# |
13 |
52f5c16c80a3
|
# This program is free software; you can redistribute it and/or |
14 |
52f5c16c80a3
|
# modify it under the terms of the GNU General Public License |
15 |
52f5c16c80a3
|
# as published by the Free Software Foundation; either version 2 |
16 |
52f5c16c80a3
|
# of the License, or (at your option) any later version. |
17 |
52f5c16c80a3
|
# |
18 |
52f5c16c80a3
|
# This program is distributed in the hope that it will be useful, |
19 |
52f5c16c80a3
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 |
52f5c16c80a3
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 |
52f5c16c80a3
|
# GNU General Public License for more details. |
22 |
52f5c16c80a3
|
# |
23 |
52f5c16c80a3
|
# You should have received a copy of the GNU General Public License |
24 |
52f5c16c80a3
|
# along with this program; if not, write to the Free Software |
25 |
52f5c16c80a3
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
26 |
52f5c16c80a3
|
# |
27 |
52f5c16c80a3
|
|
28 |
52f5c16c80a3
|
import unittest |
29 |
52f5c16c80a3
|
|
30 |
52f5c16c80a3
|
from revelation import datahandler |
31 |
52f5c16c80a3
|
|
32 |
52f5c16c80a3
|
|
33 |
52f5c16c80a3
|
|
34 |
704e07bb5692
|
class detect_handler(unittest.TestCase): |
35 |
704e07bb5692
|
"detect_handler()" |
36 |
704e07bb5692
|
|
37 |
704e07bb5692
|
def test_detect(self): |
38 |
704e07bb5692
|
"detect_handler() returns a correct handler type" |
39 |
704e07bb5692
|
|
40 |
653238141312
|
xml = """<?xml version="1.0" encoding="iso-8859-1" ?><revelationdata version="0.4.1" dataversion="1"></revelationdata>""" |
41 |
704e07bb5692
|
self.assertEquals(datahandler.detect_handler(xml), datahandler.RevelationXML) |
42 |
704e07bb5692
|
|
43 |
704e07bb5692
|
|
44 |
704e07bb5692
|
def test_unknown(self): |
45 |
704e07bb5692
|
"detect_handler() raises DetectError on unknown type" |
46 |
704e07bb5692
|
|
47 |
704e07bb5692
|
data = "this is just junk data" |
48 |
704e07bb5692
|
self.assertRaises(datahandler.DetectError, datahandler.detect_handler, data) |
49 |
704e07bb5692
|
|
50 |
704e07bb5692
|
|
51 |
704e07bb5692
|
|
52 |
52f5c16c80a3
|
class get_export_handlers(unittest.TestCase): |
53 |
52f5c16c80a3
|
"get_export_handlers()" |
54 |
52f5c16c80a3
|
|
55 |
52f5c16c80a3
|
def test_handlers(self): |
56 |
52f5c16c80a3
|
"get_export_handlers() returns only export handlers" |
57 |
52f5c16c80a3
|
|
58 |
52f5c16c80a3
|
for handler in datahandler.get_export_handlers(): |
59 |
52f5c16c80a3
|
self.assertEqual(handler.exporter, True) |
60 |
52f5c16c80a3
|
|
61 |
52f5c16c80a3
|
|
62 |
52f5c16c80a3
|
|
63 |
52f5c16c80a3
|
class get_import_handlers(unittest.TestCase): |
64 |
52f5c16c80a3
|
"get_import_handlers()" |
65 |
52f5c16c80a3
|
|
66 |
52f5c16c80a3
|
def test_handlers(self): |
67 |
52f5c16c80a3
|
"get_import_handlers() returns only import handlers" |
68 |
52f5c16c80a3
|
|
69 |
52f5c16c80a3
|
for handler in datahandler.get_import_handlers(): |
70 |
52f5c16c80a3
|
self.assertEqual(handler.importer, True) |
71 |
52f5c16c80a3
|
|
72 |
52f5c16c80a3
|
|
73 |
52f5c16c80a3
|
|
74 |
52f5c16c80a3
|
if __name__ == "__main__": |
75 |
52f5c16c80a3
|
unittest.main() |