41
41
get_packages_file([package1]) + get_packages_file([package2]),
42
42
get_packages_file([package1, package2]))
45
class FetchedPackageTests(TestCase):
44
def test_with_depends(self):
45
package = DummyFetchedPackage("foo", "1.1", depends="bar | baz")
46
self.assertEqual(textwrap.dedent("""\
49
Filename: %(filename)s
55
'filename': package.filename,
58
}), get_packages_file([package]))
61
class FetchedPackageTests(TestCaseWithFixtures):
47
63
def test_attributes(self):
48
64
package = FetchedPackage(
112
128
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "i386")
113
129
self.assertNotEqual(package1, package2)
131
def test_not_equal_different_depends(self):
132
package1 = FetchedPackage(
133
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
135
package2 = FetchedPackage(
136
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
138
self.assertNotEqual(package1, package2)
140
def test_not_equal_different_depends_one_None(self):
141
package1 = FetchedPackage(
142
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
144
package2 = FetchedPackage(
145
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
147
self.assertNotEqual(package1, package2)
149
def test_equal_same_depends(self):
150
package1 = FetchedPackage(
151
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
153
package2 = FetchedPackage(
154
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
156
self.assertEqual(package1, package2)
115
158
def test_equal_hash_equal(self):
116
159
package1 = FetchedPackage(
117
160
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
119
162
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
120
163
self.assertEqual(hash(package1), hash(package2))
165
def test_equal_hash_equal_with_depends(self):
166
package1 = FetchedPackage(
167
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
169
package2 = FetchedPackage(
170
"foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel",
172
self.assertEqual(hash(package1), hash(package2))
174
def test_from_apt(self):
175
target_package = DummyFetchedPackage("foo", "1.0")
176
source = self.useFixture(AptSourceFixture([target_package]))
177
with IsolatedAptCache([source.sources_entry]) as cache:
178
candidate = cache.cache['foo'].candidate
179
created_package = FetchedPackage.from_apt(
180
candidate, target_package.filename, target_package.content)
181
self.assertEqual(target_package, created_package)
183
def test_from_apt_with_depends(self):
184
target_package = DummyFetchedPackage(
185
"foo", "1.0", depends="bar | baz (>= 1.0), zap")
186
source = self.useFixture(AptSourceFixture([target_package]))
187
with IsolatedAptCache([source.sources_entry]) as cache:
188
candidate = cache.cache['foo'].candidate
189
created_package = FetchedPackage.from_apt(
190
candidate, target_package.filename, target_package.content)
191
self.assertEqual(target_package, created_package)
123
194
class AptCacheTests(TestCaseWithFixtures):