import repository from arizona
[raven.git] / 2.0 / python / test / storkdependencyTest.py
1 #! /usr/bin/env python
2 """
3
4 <Module>
5    storkdependencyTest
6
7 <Author>
8    Mario Gonzalez
9
10 <Started>
11    June 20, 2006
12
13 <Purpose>
14    Test module for storkdependency. See storkdependency.py for more details.
15 """
16
17
18 import os
19 import arizonaconfig
20 import arizonatransfer
21 import arizonaunittest
22 import stork
23 import storkdependency
24 import sys
25
26 class test(arizonaunittest.TestCase):
27
28    #------------------------------------------------------------------
29    # reset_options(): resets the arizonaconfig options and reloads the
30    # modules to their initial state.
31    #------------------------------------------------------------------
32    def reset_options(self):
33        reload(storkdependency)
34        reload(arizonaconfig)
35
36
37    #------------------------------------------------------------------
38    # this_satisfies
39    #------------------------------------------------------------------
40    def test_this_satisfies(self):
41        self.reset_options()
42
43        # verify correctness of package name checked
44        self.assertTrue(storkdependency.this_satisfies("foo", "", "foo"))
45        self.assertTrue(storkdependency.this_satisfies("foo", "", "foo = 1.2.3"))
46        self.assertFalse(storkdependency.this_satisfies("foo", "", "bar"))
47        self.assertFalse(storkdependency.this_satisfies("foo", "", "bar = 1.2.3"))
48
49        # if the candidate has no version #, then always return true
50        self.assertTrue(storkdependency.this_satisfies("foo", "= 1", "foo"))
51        self.assertTrue(storkdependency.this_satisfies("foo", "> 1", "foo"))
52        self.assertTrue(storkdependency.this_satisfies("foo", "< 1", "foo"))
53        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1", "foo"))
54        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1", "foo"))
55
56        # longer versions with equal prefixes are always greater
57        self.assertTrue(storkdependency.this_satisfies("foo", "> 1.1", "foo = 1.1.0"))
58        self.assertFalse(storkdependency.this_satisfies("foo", "= 1.1", "foo = 1.1.0"))
59        self.assertFalse(storkdependency.this_satisfies("foo", "<= 1.1", "foo = 1.1.0"))
60
61        # equal relational operators
62        self.assertTrue(storkdependency.this_satisfies("foo", "= 1", "foo = 1"))
63        self.assertTrue(storkdependency.this_satisfies("foo", "= 1.1", "foo = 1.1"))
64        self.assertTrue(storkdependency.this_satisfies("foo", "= 1.1", "foo = 1.1-2"))
65        # false
66        self.assertFalse(storkdependency.this_satisfies("foo", "= 1", "foo = 2"))
67        self.assertFalse(storkdependency.this_satisfies("foo", "= 1.1", "foo = 1.2"))
68
69        # greater than relational operators
70        self.assertTrue(storkdependency.this_satisfies("foo", "> 1", "foo = 2"))
71        self.assertTrue(storkdependency.this_satisfies("foo", "> 1.1", "foo = 1.2"))
72        self.assertTrue(storkdependency.this_satisfies("foo", "> 1.1", "foo = 1.2.0"))
73        self.assertTrue(storkdependency.this_satisfies("foo", "> 1.1", "foo = 1.2-1"))
74        self.assertTrue(storkdependency.this_satisfies("foo", "> 1.1-1", "foo = 1.1-2"))
75        #false
76        self.assertFalse(storkdependency.this_satisfies("foo", "> 2", "foo = 2"))
77        self.assertFalse(storkdependency.this_satisfies("foo", "> 2", "foo = 1"))
78        self.assertFalse(storkdependency.this_satisfies("foo", "> 1.2", "foo = 1.1"))
79        self.assertFalse(storkdependency.this_satisfies("foo", "> 1.2", "foo = 1.1-1"))
80        self.assertFalse(storkdependency.this_satisfies("foo", "> 1.1-2", "foo = 1.1-1"))
81        self.assertFalse(storkdependency.this_satisfies("foo", "> 1.1-2", "foo = 1.1-2"))
82
83        # less than relational operators
84        self.assertTrue(storkdependency.this_satisfies("foo", "< 2", "foo = 1"))
85        self.assertTrue(storkdependency.this_satisfies("foo", "< 1.2", "foo = 1.1"))
86        self.assertTrue(storkdependency.this_satisfies("foo", "< 1.2", "foo = 1.1.0"))
87        self.assertTrue(storkdependency.this_satisfies("foo", "< 1.2", "foo = 1.1-1"))
88        self.assertTrue(storkdependency.this_satisfies("foo", "< 1.1-2", "foo = 1.1-1"))
89        #false
90        self.assertFalse(storkdependency.this_satisfies("foo", "< 2", "foo = 2"))
91        self.assertFalse(storkdependency.this_satisfies("foo", "< 2", "foo = 3"))
92        self.assertFalse(storkdependency.this_satisfies("foo", "< 1.2", "foo = 1.3"))
93        self.assertFalse(storkdependency.this_satisfies("foo", "< 1.2", "foo = 1.3-1"))
94        self.assertFalse(storkdependency.this_satisfies("foo", "< 1.1-2", "foo = 1.1-3"))
95        self.assertFalse(storkdependency.this_satisfies("foo", "< 1.1-2", "foo = 1.1-2"))
96
97        # greater_equal than relational operators
98        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1", "foo = 2"))
99        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1", "foo = 1.2"))
100        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1", "foo = 1.2.0"))
101        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1", "foo = 1.2-1"))
102        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1-1", "foo = 1.1-2"))
103        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1", "foo = 1"))
104        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1", "foo = 1.1"))
105        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1", "foo = 1.1.0"))
106        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1", "foo = 1.1-1"))
107        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1-1", "foo = 1.1-2"))
108        self.assertTrue(storkdependency.this_satisfies("foo", ">= 1.1-1", "foo = 1.1-1"))
109        #false
110        self.assertFalse(storkdependency.this_satisfies("foo", ">= 2", "foo = 1"))
111        self.assertFalse(storkdependency.this_satisfies("foo", ">= 1.2", "foo = 1.1"))
112        self.assertFalse(storkdependency.this_satisfies("foo", ">= 1.2", "foo = 1.1-1"))
113        self.assertFalse(storkdependency.this_satisfies("foo", ">= 1.1-2", "foo = 1.1-1"))
114
115        # lessthan_equal than relational operators
116        self.assertTrue(storkdependency.this_satisfies("foo", "<= 2", "foo = 1"))
117        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1.2", "foo = 1.1"))
118        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1.2", "foo = 1.1.0"))
119        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1.2", "foo = 1.1-1"))
120        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1.1-2", "foo = 1.1-1"))
121        self.assertTrue(storkdependency.this_satisfies("foo", "<= 2", "foo = 2"))
122        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1.2", "foo = 1.2"))
123        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1.2", "foo = 1.2-1"))
124        self.assertTrue(storkdependency.this_satisfies("foo", "<= 1.1-2", "foo = 1.1-2"))
125        #false
126        self.assertFalse(storkdependency.this_satisfies("foo", "<= 2", "foo = 3"))
127        self.assertFalse(storkdependency.this_satisfies("foo", "<= 1.2", "foo = 1.3"))
128        self.assertFalse(storkdependency.this_satisfies("foo", "<= 1.2", "foo = 1.3-1"))
129        self.assertFalse(storkdependency.this_satisfies("foo", "<= 1.1-2", "foo = 1.1-3"))
130
131    #------------------------------------------------------------------
132    # find_satisfying_packages:
133    #------------------------------------------------------------------
134    def test_split_pack_name(self):
135        self.reset_options()
136        
137        (name, ver, tags) = storkdependency.split_pack_name("foo>1.0-1")
138        self.assertTrue(name == "foo");
139        self.assertTrue(ver == ">1.0-1");
140
141        (name, ver, tags) = storkdependency.split_pack_name("foo >1.0-1");
142        self.assertTrue(name == "foo");
143        self.assertTrue(ver == ">1.0-1");
144
145        (name, ver, tags) = storkdependency.split_pack_name("foo > 1.0-1");
146        self.assertTrue(name == "foo");
147        self.assertTrue(ver == "> 1.0-1");
148
149    #------------------------------------------------------------------
150    # find_satisfying_packages:
151    #------------------------------------------------------------------
152    def test_find_satisfying_packages(self):
153        pass
154
155
156    #------------------------------------------------------------------
157    # find_file_satisfying_packages
158    #------------------------------------------------------------------
159    def test_find_file_satisfying_packages(self):
160        pass
161
162
163    #------------------------------------------------------------------
164    # find_trusted_satisfying_packages
165    #------------------------------------------------------------------
166    def test_find_trusted_satisfying_packages(self):
167        pass
168
169
170    #------------------------------------------------------------------
171    # installed_satisfy
172    #------------------------------------------------------------------
173    def test_installed_satisfy(self):
174        pass
175
176
177    #------------------------------------------------------------------
178    # installed_satisfy_list
179    #------------------------------------------------------------------
180    def test_installed_satisfy_list(self):
181        pass
182
183
184    #------------------------------------------------------------------
185    # find_unsat_dependencies
186    #------------------------------------------------------------------
187    def test_find_unsat_dependencies(self):
188        pass
189
190
191    #------------------------------------------------------------------
192    # satisfy
193    #------------------------------------------------------------------
194    def test_satisfy(self):
195        pass
196
197
198
199 # Run tests
200 if __name__ == '__main__':
201     arizonaunittest.main()