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_text.py

commit
c612387bf775
parent
d1c13e095736
branch
default
tags
revelation-0.4.0

fixed typo in python path checks

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