File: test_exceptions.py

package info (click to toggle)
python-secretstorage 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 200 kB
  • ctags: 167
  • sloc: python: 695; makefile: 17; sh: 8
file content (36 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Tests for SecretStorage
# Author: Dmitry Shachnev, 2013
# License: BSD

# Various exception tests

import unittest
import secretstorage
from secretstorage.exceptions import ItemNotFoundException

class ExceptionsTest(unittest.TestCase):
	"""A test case that ensures that all SecretStorage exceptions
	are raised correctly."""

	@classmethod
	def setUpClass(cls):
		cls.bus = secretstorage.dbus_init(main_loop=False)
		cls.collection = secretstorage.get_any_collection(cls.bus)

	def test_double_deleting(self):
		item = self.collection.create_item('MyItem',
			{'application': 'secretstorage-test'}, b'pa$$word')
		item.delete()
		self.assertRaises(ItemNotFoundException, item.delete)

	def test_non_existing_item(self):
		self.assertRaises(ItemNotFoundException, secretstorage.Item,
			self.bus, '/not/existing/path')

	def test_non_existing_collection(self):
		self.assertRaises(ItemNotFoundException,
			secretstorage.get_collection_by_alias,
			self.bus, 'non-existing-alias')

if __name__ == '__main__':
	unittest.main()