1
# -*- coding: utf-8 -*-
3
Created on Jun 30, 2010
10
from model.profile_collection import ProfileCollection
11
from model.profile import Profile
14
class Test(unittest.TestCase):
25
def test_put_get(self):
27
profile = Profile(name)
28
collection = ProfileCollection()
29
collection.put(profile)
30
retrieved_profile = collection.get(name)
31
assert retrieved_profile is profile
34
def test_get_non_existing(self):
35
collection = ProfileCollection()
36
self.assertRaises(exceptions.AttributeError, collection.get, "anything")
39
def test_contains(self):
41
profile = Profile(name)
42
collection = ProfileCollection()
43
has_profile = collection.contains("anything")
44
assert has_profile is False
45
collection.put(profile)
46
has_profile = collection.contains(name)
47
assert has_profile is True
50
def test_remove(self):
52
profile = Profile(name)
53
collection = ProfileCollection()
54
collection.put(profile)
55
has_profile = collection.contains(name)
56
assert has_profile is True
57
collection.remove(name)
58
has_profile = collection.contains(name)
59
assert has_profile is False
62
def test_list_choices(self):
63
profile3 = Profile("B3")
64
profile2 = Profile("B2")
65
profile1 = Profile("A1")
66
collection = ProfileCollection()
67
collection.put(profile3)
68
collection.put(profile2)
69
collection.put(profile1)
70
collection.put(profile3)
71
tuple = collection.list_choices()
72
assert tuple is ("A1", "B2", "C3")
75
if __name__ == "__main__":
76
#import sys;sys.argv = ['', 'Test.testName']
b'\\ No newline at end of file'