~wmmapper/wmmapper/wmmapper

« back to all changes in this revision

Viewing changes to wmmapper-test/model/profile_collection_test.py

  • Committer: Alexander Bethke
  • Date: 2010-06-30 21:29:19 UTC
  • Revision ID: oolongbrothers@gmx.net-20100630212919-2r26xf9oyrben447
Created the ProfileCollectionTest unit test in the new wmmapper-test source folder.
Initial skelettal structure for ProfileCollection class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
'''
 
3
Created on Jun 30, 2010
 
4
 
 
5
@author: alex
 
6
'''
 
7
 
 
8
import unittest
 
9
import exceptions
 
10
from model.profile_collection import ProfileCollection
 
11
from model.profile import Profile
 
12
 
 
13
 
 
14
class Test(unittest.TestCase):
 
15
 
 
16
 
 
17
    def setUp(self):
 
18
        pass
 
19
 
 
20
 
 
21
    def tearDown(self):
 
22
        pass
 
23
 
 
24
 
 
25
    def test_put_get(self):
 
26
        name = "A1"
 
27
        profile = Profile(name)
 
28
        collection = ProfileCollection()
 
29
        collection.put(profile)
 
30
        retrieved_profile = collection.get(name)
 
31
        assert retrieved_profile is profile
 
32
 
 
33
 
 
34
    def test_get_non_existing(self):
 
35
        collection = ProfileCollection()
 
36
        self.assertRaises(exceptions.AttributeError, collection.get, "anything")
 
37
 
 
38
 
 
39
    def test_contains(self):
 
40
        name = "A1"
 
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
 
48
 
 
49
 
 
50
    def test_remove(self):
 
51
        name = "A1"
 
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
 
60
 
 
61
 
 
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")
 
73
 
 
74
 
 
75
if __name__ == "__main__":
 
76
    #import sys;sys.argv = ['', 'Test.testName']
 
77
    unittest.main()
 
 
b'\\ No newline at end of file'