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 again

erikg / Revelation

Revelation is a password manager for the GNOME desktop, released under the GNU GPL license. It stores all your accounts and passwords in a single, secure place, and gives you access to it through a user-friendly graphical interface.

Clone this repository (size: 2.1 MB): HTTPS / SSH
hg clone https://bitbucket.org/erikg/revelation
hg clone ssh://hg@bitbucket.org/erikg/revelation

Revelation / test / datahandler_xhtml.py

commit
35864a73a048
parent
070d0062872f
branch
default
tags
revelation-0.4.3

bumped version number to 0.4.3

1
c094b5acab4e
#!/usr/bin/env python
2
c094b5acab4e
3
c094b5acab4e
#
4
35864a73a048
# Revelation 0.4.3 - a password manager for GNOME 2
5
c094b5acab4e
# http://oss.codepoet.no/revelation/
6
c094b5acab4e
# $Id$
7
c094b5acab4e
#
8
c094b5acab4e
# Unit tests for XHTML datahandler module
9
c094b5acab4e
#
10
c094b5acab4e
#
11
c094b5acab4e
# Copyright (c) 2003-2005 Erik Grinaker
12
c094b5acab4e
#
13
c094b5acab4e
# This program is free software; you can redistribute it and/or
14
c094b5acab4e
# modify it under the terms of the GNU General Public License
15
c094b5acab4e
# as published by the Free Software Foundation; either version 2
16
c094b5acab4e
# of the License, or (at your option) any later version.
17
c094b5acab4e
#
18
c094b5acab4e
# This program is distributed in the hope that it will be useful,
19
c094b5acab4e
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
c094b5acab4e
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
c094b5acab4e
# GNU General Public License for more details.
22
c094b5acab4e
#
23
c094b5acab4e
# You should have received a copy of the GNU General Public License
24
c094b5acab4e
# along with this program; if not, write to the Free Software
25
c094b5acab4e
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26
c094b5acab4e
#
27
c094b5acab4e
28
c094b5acab4e
import unittest, xml.dom.minidom
29
c094b5acab4e
30
c094b5acab4e
from revelation import data, datahandler, entry
31
c094b5acab4e
32
c094b5acab4e
33
c094b5acab4e
34
c094b5acab4e
class XHTML(unittest.TestCase):
35
c094b5acab4e
	"XHTML()"
36
c094b5acab4e
37
c094b5acab4e
	def test_attrs(self):
38
c094b5acab4e
		"XHTML has sane attrs"
39
c094b5acab4e
40
c094b5acab4e
		self.assertEquals(datahandler.XHTML.name, "XHTML / CSS")
41
c094b5acab4e
		self.assertEquals(datahandler.XHTML.importer, False)
42
c094b5acab4e
		self.assertEquals(datahandler.XHTML.exporter, True)
43
c094b5acab4e
		self.assertEquals(datahandler.XHTML.encryption, False)
44
c094b5acab4e
45
c094b5acab4e
46
c094b5acab4e
47
c094b5acab4e
class XHTML_export_data(unittest.TestCase):
48
c094b5acab4e
	"XHTML.export_data()"
49
c094b5acab4e
50
c094b5acab4e
	def setUp(self):
51
c094b5acab4e
		"set up common facilities for tests"
52
c094b5acab4e
53
c094b5acab4e
		self.entrystore = data.EntryStore()
54
c094b5acab4e
55
c094b5acab4e
		e = entry.GenericEntry()
56
c094b5acab4e
		e.name = "Generic entry"
57
c094b5acab4e
		e.description = "A test entry"
58
c094b5acab4e
		e.updated = 1098822251
59
c094b5acab4e
		e[entry.HostnameField] = "localhost"
60
c094b5acab4e
		e[entry.UsernameField] = "erikg"
61
c094b5acab4e
		e[entry.PasswordField] = "pwtest"
62
c094b5acab4e
		self.entrystore.add_entry(e)
63
c094b5acab4e
64
c094b5acab4e
		f = entry.FolderEntry()
65
c094b5acab4e
		f.name = "Folder"
66
c094b5acab4e
		fiter = self.entrystore.add_entry(f)
67
c094b5acab4e
68
c094b5acab4e
		e = entry.WebEntry()
69
c094b5acab4e
		e.name = "Web entry"
70
c094b5acab4e
		e.description = "A test web entry"
71
c094b5acab4e
		e.updated = 123456789
72
c094b5acab4e
		e[entry.URLField] = "http://www.slashdot.org/"
73
c094b5acab4e
		e[entry.UsernameField] = "erikg"
74
c094b5acab4e
		e[entry.PasswordField] = "pwtest"
75
c094b5acab4e
		self.entrystore.add_entry(e, fiter)
76
c094b5acab4e
77
c094b5acab4e
78
c094b5acab4e
	def test_wellformed(self):
79
c094b5acab4e
		"XHTML.export_data() generates well-formed XML"
80
c094b5acab4e
81
c094b5acab4e
		xml.dom.minidom.parseString(datahandler.XHTML().export_data(self.entrystore))
82
c094b5acab4e
83
c094b5acab4e
84
c094b5acab4e
85
c094b5acab4e
if __name__ == "__main__":
86
c094b5acab4e
	unittest.main()
87
c094b5acab4e