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 37 38 39
|
# Tests for SecretStorage
# Author: Dmitry Shachnev, 2013
# License: BSD
# This file tests the secretstorage.Collection class.
import unittest
from secretstorage import dbus_init, get_any_collection, get_all_collections, Collection
class CollectionTest(unittest.TestCase):
"""A test case that tests that all common methods of Collection
class work and do not crash."""
@classmethod
def setUpClass(cls):
cls.bus = dbus_init(main_loop=False)
cls.collection = get_any_collection(cls.bus)
def test_all_collections(self):
labels = map(Collection.get_label, get_all_collections(self.bus))
self.assertIn(self.collection.get_label(), labels)
def test_all_items(self):
for item in self.collection.get_all_items():
item.get_label()
def test_create_empty_item(self):
item = self.collection.create_item('', {}, b'')
item.delete()
def test_label(self):
old_label = self.collection.get_label()
self.collection.set_label('Hello!')
self.assertEqual(self.collection.get_label(), 'Hello!')
self.collection.set_label(old_label)
self.assertEqual(self.collection.get_label(), old_label)
if __name__ == '__main__':
unittest.main()
|