tests: Lots of fixes

Thanks to the great work done by Gökhan Göktürk.
This commit is contained in:
Fatih Aşıcı
2010-07-11 08:45:48 +00:00
parent 3782c3bcf0
commit 1593858786
19 changed files with 99 additions and 100 deletions
+3 -3
View File
@@ -16,8 +16,8 @@ class ConfigFileTestCase(unittest.TestCase):
def testBuildDefaults(self):
cf = self.cf
self.assertEqual(cf.build.jobs, cf.build['jobs'])
assert not cf.build.generateDebug
assert not cf.build.enableSandbox
assert not cf.build.defaults.generateDebug
assert cf.build.defaults.enableSandbox #default is taken from 2009.2
self.assertEqual(cf.build.compressionlevel, cf.build['compressionlevel'])
self.assertEqual(cf.build.fallback, cf.build['fallback'])
@@ -40,7 +40,7 @@ class ConfigFileTestCase(unittest.TestCase):
self.assertEqual(cf.dirs.kde_dir, '/usr/kde/4')
self.assertEqual(cf.dirs.compiled_packages_dir, '/var/cache/pisi/packages')
self.assertEqual(cf.general.architecture, 'i686')
self.assertEqual(cf.general.distribution_release, '2008')
self.assertEqual(cf.general.distribution_release, '2009')
def testValuesExists(self):
cf = self.cf
+4 -2
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -15,7 +15,9 @@ import pisi
class ComponentDBTestCase(testcase.TestCase):
componentdb = pisi.db.componentdb.ComponentDB()
def setUp(self):
testcase.TestCase.setUp(self)
self.componentdb = pisi.db.componentdb.ComponentDB()
def testHasComponent(self):
assert self.componentdb.has_component("system.base", "pardus-2007")
+20 -11
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -14,32 +14,38 @@ import testcase
import pisi
class InstallDBTestCase(testcase.TestCase):
installdb = pisi.db.installdb.InstallDB()
def setUp(self):
testcase.TestCase.setUp(self)
self.installdb = pisi.db.installdb.InstallDB()
def testGetPackage(self):
pisi.api.install(["ethtool"])
pkg = self.installdb.get_package("ethtool")
idb = pisi.db.installdb.InstallDB()
pkg = idb.get_package("ethtool")
assert type(pkg) == pisi.metadata.Package
assert pkg.name == "ethtool"
pisi.api.remove(["ethtool"])
def testHasPackage(self):
pisi.api.install(["ethtool"])
self.installdb = pisi.db.installdb.InstallDB()
assert not self.installdb.has_package("hedehodo")
assert self.installdb.has_package("ethtool")
pisi.api.remove(["ethtool"])
def testListInstalled(self):
pisi.api.install(["ethtool"])
self.installdb = pisi.db.installdb.InstallDB()
assert set(self.installdb.list_installed()) == set(['zlib', 'pam', 'shadow',
'jpeg', 'libidn', 'db4',
'cracklib', 'openssl',
'curl', 'bash', 'ethtool'])
pisi.api.remove(["ethtool"])
def testGetVersion(self):
pisi.api.install(["ethtool"])
self.installdb = pisi.db.installdb.InstallDB()
version, release, build = self.installdb.get_version("zlib")
assert version == "0.3"
assert release == "1"
@@ -48,32 +54,35 @@ class InstallDBTestCase(testcase.TestCase):
def testGetFiles(self):
pisi.api.install(["ethtool"])
self.installdb = pisi.db.installdb.InstallDB()
files = self.installdb.get_files("ethtool")
assert files.list[0].path == "usr/bin/ethtool"
pisi.api.remove(["ethtool"])
def testGetInfo(self):
pisi.api.install(["ethtool"])
info = self.installdb.get_info("ethtool")
idb = pisi.db.installdb.InstallDB()
info = idb.get_info("ethtool")
assert info.__class__ == pisi.db.installdb.InstallInfo
assert info.distribution == "Pardus"
pisi.api.remove(["ethtool"])
def testGetReverseDependencies(self):
pisi.api.install(["ethtool"])
pisi.api.install(["ctorrent"])
self.installdb = pisi.db.installdb.InstallDB()
revdeps = self.installdb.get_rev_deps("openssl")
assert set(["ctorrent", "curl"]) == set(map(lambda x:x[0], revdeps))
pisi.api.remove(["ctorrent"])
pisi.api.remove(["ethtool"])
def testAddRemovePackage(self):
pisi.api.install(["ctorrent"])
self.installdb = pisi.db.installdb.InstallDB()
assert self.installdb.has_package("ctorrent")
assert not self.installdb.has_package("ethtool")
pisi.api.install(["ethtool"])
self.installdb = pisi.db.installdb.InstallDB()
assert self.installdb.has_package("ctorrent")
assert self.installdb.has_package("ethtool")
pisi.api.remove(["ctorrent"])
@@ -101,11 +110,11 @@ class InstallDBTestCase(testcase.TestCase):
def testSearchPackage(self):
pisi.api.set_comar(False)
self.installdb = pisi.db.installdb.InstallDB()
assert not self.installdb.has_package("ethtool")
assert not self.installdb.search_package(["ethtool"])
pisi.api.install(["ethtool"])
self.installdb = pisi.db.installdb.InstallDB()
assert self.installdb.search_package(["et", "tool", "h"]) == ["ethtool"]
pisi.api.remove(["ethtool"])
pisi.api.set_comar(True)
+2 -2
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -54,7 +54,7 @@ class ItemByRepoTestCase(testcase.TestCase):
assert self.testdb.tdb.has_item("acpica")
def testWhichRepo(self):
assert self.testdb.tdb.which_repo("acpica") == "pardus-2007"
assert self.testdb.tdb.which_repo("aggdraw") == "pardus-2007"
assert self.testdb.tdb.which_repo("kmess") == "contrib-2007"
def testGetItemAndRepository(self):
+5 -6
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -14,7 +14,7 @@ import unittest
import pisi.db.lazydb as lazydb
class TestDB(lazydb.LazyDB):
def init(self):
self.testfield = True
@@ -25,17 +25,16 @@ class LazyDBTestCase(unittest.TestCase):
def testDatabaseMethodForcingInit(self):
db = TestDB()
db.getTestField()
assert db.getTestField()
assert db.__dict__.has_key("testfield")
del TestDB._the_instance
db._delete()
def testDatabaseWithoutInit(self):
db = TestDB()
assert not db.__dict__.has_key("testfield")
del TestDB._the_instance
db._delete()
def testSingletonBehaviour(self):
db = TestDB()
db2 = TestDB()
assert id(db) == id(db2)
+4 -2
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -15,7 +15,9 @@ import pisi
class PackageDBTestCase(testcase.TestCase):
packagedb = pisi.db.packagedb.PackageDB()
def setUp(self):
testcase.TestCase.setUp(self)
self.packagedb = pisi.db.packagedb.PackageDB()
def testGetPackage(self):
pkg = self.packagedb.get_package("ncftp", "pardus-2007")
+5 -3
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -15,7 +15,9 @@ import pisi
class RepoDBTestCase(testcase.TestCase):
repodb = pisi.db.repodb.RepoDB()
def setUp(self):
testcase.TestCase.setUp(self)
self.repodb = pisi.db.repodb.RepoDB()
def testAddRemoveRepo(self):
assert "contrib-2007-src" not in self.repodb.list_repos()
@@ -54,7 +56,7 @@ class RepoDBTestCase(testcase.TestCase):
def testRepoOrder(self):
repoorder = pisi.db.repodb.RepoOrder()
assert repoorder.get_order() == ['pardus-2007', 'contrib-2007', 'pardus-2007-src']
repoorder.add("test-repo", "http://test-repo/pisi-index.xml.bz2")
assert repoorder.get_order() == ['pardus-2007', 'contrib-2007', 'pardus-2007-src', 'test-repo']
+7 -3
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -14,8 +14,12 @@ import testcase
import pisi
class SourceDBTestCase(testcase.TestCase):
sourcedb = pisi.db.sourcedb.SourceDB()
def setUp(self):
testcase.TestCase.setUp(self)
self.sourcedb = pisi.db.sourcedb.SourceDB()
def testListSources(self):
assert set(self.sourcedb.list_sources()) == set(['ethtool', 'nfdump', 'shadow', 'libidn',
-1
View File
@@ -22,4 +22,3 @@ class TestCase(unittest.TestCase):
pisi.api.update_repo("pardus-2007")
pisi.api.update_repo("contrib-2007")
pisi.api.update_repo("pardus-2007-src")
+4 -15
View File
@@ -15,31 +15,20 @@ class DependencyTestCase(unittest.TestCase):
depinfo = pisi.dependency.Dependency(relation)
dictionary = {"ethtool": [" "],"zlib":["a","b"],"ctorrent":["c"]}
assert not pisi.dependency.dict_satisfies_dep(dictionary,depinfo)
assert not depinfo.satisfied_by_dict_repo(dictionary)
depinf = pisi.dependency.Dependency(rel)
assert not pisi.dependency.dict_satisfies_dep(dictionary,depinf)
assert not depinf.satisfied_by_dict_repo(dictionary)
def testInstalledSatisfiesDep(self):
pisi.api.install(["ctorrent"])
relation = pisi.relation.Relation()
relation.package = "ctorrent"
depinfo = pisi.dependency.Dependency(relation)
assert not pisi.dependency.installed_satisfies_dep(depinfo)
assert not depinfo.satisfied_by_installed()
def testRepoSatisfiesDependency(self):
pisi.api.install(["ethtool"])
relation = pisi.relation.Relation()
relation.package = "ctorrent"
depinfo = pisi.dependency.Dependency(relation)
assert not pisi.dependency.repo_satisfies_dep(depinfo)
def testSatisfiesRuntimeDeps(self):
pisi.api.install(["ethtool"])
assert pisi.dependency.satisfies_runtime_deps("ethtool")
pisi.api.install(["ctorrent"])
assert pisi.dependency.satisfies_runtime_deps("ctorrent")
def testInstallable(self):
assert pisi.dependency.installable("zlib")
assert pisi.dependency.installable("ethtool")
assert not pisi.dependency.installable("paket")
assert not depinfo.satisfied_by_repo()
+2 -2
View File
@@ -14,7 +14,7 @@ class FetchTestCase(unittest.TestCase):
unittest.TestCase.setUp(self)
self.spec = SpecFile()
self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml')
self.url = uri.URI(self.spec.source.archive.uri)
self.url = uri.URI(self.spec.source.archive[0].uri)
self.url.set_auth_info(("user", "pass"))
self.destpath = ctx.config.archives_dir()
self.fetch = Fetcher(self.url, self.destpath)
@@ -23,7 +23,7 @@ class FetchTestCase(unittest.TestCase):
self.fetch.fetch()
fetchedFile = os.path.join(self.destpath, self.url.filename())
if os.access(fetchedFile, os.R_OK):
self.assertEqual(util.sha1_file(fetchedFile),self.spec.source.archive.sha1sum)
self.assertEqual(util.sha1_file(fetchedFile),self.spec.source.archive[0].sha1sum)
os.remove(fetchedFile)
def testFetcherFunctions(self):
+4 -13
View File
@@ -9,10 +9,9 @@ class FileTestCase(unittest.TestCase):
unittest.TestCase.setUp(self)
def testMakeUri(self):
self.spec = SpecFile()
self.url = uri.URI(self.spec.source.archive.uri)
f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
self.assert_(f.make_uri('uri'))
spec = SpecFile("repos/pardus-2007/system/base/curl/pspec.xml")
url = uri.URI(spec.source.archive[0].uri)
self.assert_(File.make_uri(url))
def testChooseMethod(self):
compress = File('repos/contrib-2007/pisi-index.xml.bz2', File.read)
@@ -28,16 +27,8 @@ class FileTestCase(unittest.TestCase):
r = f.readlines()
assert (len(r) > 0)
def testIsatty(self):
f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
assert not f.isatty()
def testFileNo(self):
f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
assert not 3 == f.fileno()
def testRemoteRead(self):
f = File('http://uludag.org.tr/bulten/index.html', File.read)
f = File('http://www.pardus.org.tr/urunler/pardus-2009.2-Geronticus_eremita-surum-notlari-tr.html', File.read)
r = f.readlines()
assert (len(r) > 0)
+12 -13
View File
@@ -6,17 +6,17 @@ from pisi import graph
class GraphTestCase(unittest.TestCase):
def setUp(self):
self.g0 = pisi.graph.Digraph()
self.g0.add_edge(self,(1,2))
self.g0.add_edge(self,(1,3))
self.g0.add_edge(self,(2,3))
self.g0.add_edge(self,(3,4))
self.g0.add_edge(self,(4,1))
self.g0.add_edge(1,2)
self.g0.add_edge(1,3)
self.g0.add_edge(2,3)
self.g0.add_edge(3,4)
self.g0.add_edge(4,1)
self.g1 = pisi.graph.Digraph()
self.g1.add_edge(self,(0,2))
self.g1.add_edge(self,(0,3))
self.g1.add_edge(self,(2,4))
self.g1.add_edge(self,(3,4))
self.g1.add_edge(0,2)
self.g1.add_edge(0,3)
self.g1.add_edge(2,4)
self.g1.add_edge(3,4)
def testHasVertex(self):
assert not self.g0.has_vertex(5)
@@ -28,11 +28,10 @@ class GraphTestCase(unittest.TestCase):
assert not self.g1.has_edge(2,3)
def testCycle(self):
assert self.g0.cycle_free()
assert not self.g0.cycle_free()
assert self.g1.cycle_free()
def testTopologicalSort(self):
order = self.g1.topological_sort()
self.assertEqual(not order[0], 0)
self.assertEqual(order[len(order)-1],(3,4))
assert order[0] == 0
assert order[-1] == 4
+6 -6
View File
@@ -9,12 +9,12 @@ class RelationTestCase(unittest.TestCase):
relation.package = "ethtool"
# Test version = X
relation.version = "6"
relation.version = "0.3"
assert pisi.relation.installed_package_satisfies(relation)
relation.version = None
# Test versionFrom = X
relation.versionFrom = "3"
relation.versionFrom = "0.3"
assert pisi.relation.installed_package_satisfies(relation)
relation.versionFrom = "8"
assert not pisi.relation.installed_package_satisfies(relation)
@@ -23,15 +23,15 @@ class RelationTestCase(unittest.TestCase):
#Test versionTo = X
relation.versionTo = "8"
assert pisi.relation.installed_package_satisfies(relation)
relation.versionTo = "3"
relation.versionTo = "0.1"
assert not pisi.relation.installed_package_satisfies(relation)
relation.versionTo = None
#Test release = X
relation.release = "3"
assert pisi.relation.installed_package_satisfies(relation)
relation.release = "1"
assert not pisi.relation.installed_package_satisfies(relation)
relation.release = "1"
assert pisi.relation.installed_package_satisfies(relation)
relation.release = None
#test releaseFrom = X
@@ -44,7 +44,7 @@ class RelationTestCase(unittest.TestCase):
#test releaseTo = X
relation.releaseTo = "7"
assert pisi.relation.installed_package_satisfies(relation)
relation.releaseTo = "1"
relation.releaseTo = "0"
assert not pisi.relation.installed_package_satisfies(relation)
relation.releaseTo = None
+2 -1
View File
@@ -12,9 +12,10 @@ class ReplaceTestCase(unittest.TestCase):
replace = pisi.replace.Replace(relation)
replace.package = "zlib"
# Check if the replaced package is installed
self.assert_(pisi.replace.installed_package_replaced(replace))
repinfo = pisi.replace.Replace(relation)
repinfo.package = "ctorrent"
self.assert_(pisi.replace.installed_package_replaced(repinfo))
assert not pisi.replace.installed_package_replaced(repinfo)
pisi.api.remove(["ethtool"])
+5 -5
View File
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, TUBITAK/UEKAE
# Copyright (C) 2007-2010, TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -56,9 +56,9 @@ pspecTemplate = """<?xml version="1.0" ?>
componentsTemplate = """
<Component>
<Name>%(name)s</Name>
<LocalName xml:lang="tr">%(local_name)s</LocalName>
<Summary xml:lang="tr">%(summary)s</Summary>
<Description xml:lang="tr">%(description)s</Description>
<LocalName>%(local_name)s</LocalName>
<Summary>%(summary)s</Summary>
<Description>%(description)s</Description>
<Group>system</Group>
<Packager>
<Name>Joe Packager</Name>
@@ -87,7 +87,7 @@ distributionTemplate = """
<PISI>
<SourceName>%(sourcename)s</SourceName>
<Version>%(version)s</Version>
<Description xml:lang="tr">%(description)s</Description>
<Description>%(description)s</Description>
<Type>Core</Type>
<Obsoletes>
%(obsoletes)s
+9 -5
View File
@@ -58,13 +58,17 @@ class ShellTestCase(unittest.TestCase):
self.assertEqual(os.path.islink('tests/testdirectory/sample'),False)
def testCopy(self):
from pisi.actionsapi.shelltools import echo
from pisi.actionsapi.shelltools import copy
copy('/pisi/tests', '/pisi/tests-copy')
self.assertEqual(os.path.islink('pisi/tests-copy'),False)
copy('./tests', './tests-copy')
self.assertEqual(os.path.islink('./tests-copy'),False)
shutil.rmtree("tests-copy")
copy('pisi/tests/scripts/sync-licenses', 'pisi/tests/scripts/sync-licenses-copy')
self.assertEqual(os.path.islink('pisi/tests/scripts/sync-licenses-copy'),False)
echo('tests/echo-file', 'subject eco')
copy('./tests/echo-file', './tests/echo-file-copy')
self.assertEqual(os.path.islink('./tests/echo-file-copy'), False)
os.remove("tests/echo-file")
def testIsLink(self):
from pisi.actionsapi.shelltools import sym
@@ -86,7 +90,7 @@ class ShellTestCase(unittest.TestCase):
assert not isDirectory('doc/dependency.pdf')
assert isDirectory('/usr/lib')
assert isDirectory('/etc/pisi')
assert not isDirectory('/tests/shelltest.py')
assert not isDirectory('tests/shelltest.py')
def testRealPath(self):
from pisi.actionsapi.shelltools import realPath
+4 -5
View File
@@ -1,30 +1,29 @@
import unittest
import pisi.sourcearchive
from pisi.specfile import SpecFile
#import pisi.fetcher
class SourceArchiveTestCase(unittest.TestCase):
def testFetch(self):
spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml')
targetDir = '/tmp/tests'
srcarch = pisi.sourcearchive.SourceArchive(spec,targetDir)
srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0], targetDir)
self.assert_(not srcarch.fetch())
def testIscached(self):
spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml')
targetDir = '/tmp/tests'
srcarch = pisi.sourcearchive.SourceArchive(spec,targetDir)
srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0], targetDir)
assert srcarch.is_cached()
def testIscached(self):
spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml')
targetDir = '/tmp/tests'
srcarch = pisi.sourcearchive.SourceArchive(spec,targetDir)
srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0], targetDir)
self.assert_(not srcarch.unpack())
def testUnpack(self):
spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml')
targetDir = '/tmp/tests'
srcarch = pisi.sourcearchive.SourceArchive(spec,targetDir)
srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0], targetDir)
srcarch.unpack()
+1 -2
View File
@@ -10,8 +10,7 @@ class UriTestCase(unittest.TestCase):
unittest.TestCase.setUp(self)
def testSetUri(self):
self.spec = SpecFile()
self.url = uri.URI(self.spec.source.archive.uri)
self.url = uri.URI()
self.url.set_uri('uri')
assert 'uri' == self.url.get_uri()
self.url.set_uri('urix')