tests: Lots of fixes
Thanks to the great work done by Gökhan Göktürk.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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']
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user