Change to project/trunk,tags,branches style

This commit is contained in:
Faik Uygur
2009-10-14 12:42:24 +00:00
commit 54e89f07b4
1121 changed files with 136747 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.pyc
+11
View File
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
+83
View File
@@ -0,0 +1,83 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import testcase
import pisi
class ComponentDBTestCase(testcase.TestCase):
componentdb = pisi.db.componentdb.ComponentDB()
def testHasComponent(self):
assert self.componentdb.has_component("system.base", "pardus-2007")
assert not self.componentdb.has_component("hede.hodo", "pardus-2007")
assert self.componentdb.has_component("applications.network", "contrib-2007")
assert not self.componentdb.has_component("hede.hodo", "contrib-2007")
assert self.componentdb.has_component("applications.network")
def testListComponents(self):
assert set(self.componentdb.list_components("pardus-2007")) == set(["system", "system.base",
"applications", "applications.network"])
assert set(self.componentdb.list_components("contrib-2007")) == set(["applications", "applications.util",
"applications.network"])
assert set(self.componentdb.list_components()) == set(["system", "system.base",
"applications", "applications.network",
"applications.util"])
def testGetComponent(self):
component = self.componentdb.get_component("applications.network")
assert component.name == "applications.network"
assert "ncftp" in component.packages
assert "lynx" not in component.packages
component = self.componentdb.get_component("applications.network", "contrib-2007")
assert component.name == "applications.network"
assert "lynx" in component.packages
assert "ncftp" not in component.packages
def testGetUnionComponent(self):
component = self.componentdb.get_union_component("applications.network")
assert component.name == "applications.network"
assert "lynx" in component.packages
assert "ncftp" in component.packages
def testGetPackages(self):
packages = self.componentdb.get_packages("applications.network")
assert "ncftp" in packages
assert "lynx" not in packages
packages = self.componentdb.get_packages("applications.network", "contrib-2007")
assert "lynx" in packages
assert "ncftp" not in packages
packages = self.componentdb.get_packages("applications", "contrib-2007", walk = True)
assert "cpulimit" and "lynx" in packages
assert "ncftp" not in packages
def testGetUnionPackages(self):
packages = self.componentdb.get_union_packages("applications.network")
assert "ncftp" in packages
assert "lynx" in packages
assert "cpulimit" not in packages
packages = self.componentdb.get_union_packages("applications", walk = True)
assert "ncftp" and "lynx" and "cpulimit" in packages
def testSearchComponent(self):
packages = self.componentdb.search_component(["applic"])
assert set(packages) == set(['applications', 'applications.network', 'applications.util'])
packages = self.componentdb.search_component(["system", "base"], repo="pardus-2007")
assert set(packages) == set(["system.base"])
packages = self.componentdb.search_component(["system", "base"], repo="contrib-2007")
assert not packages
+68
View File
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import testcase
import pisi
class FilesDBTestCase(testcase.TestCase):
filesdb = pisi.db.filesdb.FilesDB()
def testHasFile(self):
assert not self.filesdb.has_file("usr/bin/ethtool")
pisi.api.install(["ethtool"])
assert self.filesdb.has_file("usr/bin/ethtool")
pisi.api.remove(["ethtool"])
assert not self.filesdb.has_file("usr/bin/ethtool")
def testGetFile(self):
pisi.api.install(["ethtool"])
pkg, path = self.filesdb.get_file("usr/bin/ethtool")
assert pkg == "ethtool"
assert path == "usr/bin/ethtool"
pisi.api.remove(["ethtool"])
assert not self.filesdb.has_file("usr/bin/ethtool")
def testAddRemoveFiles(self):
fileinfo1 = pisi.files.FileInfo()
fileinfo1.path = "etc/pisi/pisi.conf"
fileinfo2 = pisi.files.FileInfo()
fileinfo2.path = "etc/pisi/mirrors.conf"
files = pisi.files.Files()
files.list.append(fileinfo1)
files.list.append(fileinfo2)
assert not self.filesdb.has_file("etc/pisi/pisi.conf")
assert not self.filesdb.has_file("etc/pisi/mirrors.conf")
self.filesdb.add_files("pisi", files)
assert self.filesdb.has_file("etc/pisi/pisi.conf")
assert self.filesdb.has_file("etc/pisi/mirrors.conf")
pkg, path = self.filesdb.get_file("etc/pisi/pisi.conf")
assert pkg == "pisi"
# FIXME: inconsistency in filesdb.py add_remove and remove_remove parameters
self.filesdb.remove_files(files.list)
assert not self.filesdb.has_file("etc/pisi/pisi.conf")
assert not self.filesdb.has_file("etc/pisi/mirrors.conf")
def testSearchFile(self):
assert not self.filesdb.search_file("ethtool")
pisi.api.install(["ethtool"])
found = self.filesdb.search_file("ethtool")
pkg, files = found[0]
assert set(files) == set(['usr/bin/ethtool'])
pisi.api.remove(["ethtool"])
+111
View File
@@ -0,0 +1,111 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import testcase
import pisi
class InstallDBTestCase(testcase.TestCase):
installdb = pisi.db.installdb.InstallDB()
def testGetPackage(self):
pisi.api.install(["ethtool"])
pkg = self.installdb.get_package("ethtool")
assert type(pkg) == pisi.metadata.Package
assert pkg.name == "ethtool"
pisi.api.remove(["ethtool"])
def testHasPackage(self):
pisi.api.install(["ethtool"])
assert not self.installdb.has_package("hedehodo")
assert self.installdb.has_package("ethtool")
pisi.api.remove(["ethtool"])
def testListInstalled(self):
pisi.api.install(["ethtool"])
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"])
version, release, build = self.installdb.get_version("zlib")
assert version == "0.3"
assert release == "1"
assert build == None
pisi.api.remove(["ethtool"])
def testGetFiles(self):
pisi.api.install(["ethtool"])
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")
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"])
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"])
assert self.installdb.has_package("ctorrent")
assert not self.installdb.has_package("ethtool")
pisi.api.install(["ethtool"])
assert self.installdb.has_package("ctorrent")
assert self.installdb.has_package("ethtool")
pisi.api.remove(["ctorrent"])
pisi.api.remove(["ethtool"])
def testMarkListPending(self):
pisi.api.set_comar(False)
assert not self.installdb.has_package("ethtool")
pisi.api.install(["ethtool"])
assert "ethtool" in self.installdb.list_pending()
pisi.api.remove(["ethtool"])
assert "ethtool" not in self.installdb.list_pending()
pisi.api.set_comar(True)
def testClearPending(self):
pisi.api.set_comar(False)
assert not self.installdb.has_package("ethtool")
pisi.api.install(["ethtool"])
assert "ethtool" in self.installdb.list_pending()
self.installdb.clear_pending("ethtool")
assert "ethtool" not in self.installdb.list_pending()
pisi.api.remove(["ethtool"])
assert "ethtool" not in self.installdb.list_pending()
pisi.api.set_comar(True)
def testSearchPackage(self):
pisi.api.set_comar(False)
assert not self.installdb.has_package("ethtool")
assert not self.installdb.search_package(["ethtool"])
pisi.api.install(["ethtool"])
assert self.installdb.search_package(["et", "tool", "h"]) == ["ethtool"]
pisi.api.remove(["ethtool"])
pisi.api.set_comar(True)
+91
View File
@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import testcase
import pisi.db.itembyrepo
class TestDB:
def __init__(self):
self.packages = {}
self.obsoletes = {}
self.packages["pardus-2007"] = {"aggdraw":"package aggdraw",
"acpica":"package acpica"}
self.packages["contrib-2007"] = {"kdiff3":"package kdiff3",
"kmess":"package kmess"}
self.obsoletes["pardus-2007"] = ["wengophone", "rar"]
self.obsoletes["contrib-2007"] = ["xara"]
self.tdb = pisi.db.itembyrepo.ItemByRepo(self.packages)
self.odb = pisi.db.itembyrepo.ItemByRepo(self.obsoletes)
# original item_repos in ItemByRepo uses repodb.list_repos
def item_repos(repo=None):
repos = ["pardus-2007", "contrib-2007"]
if repo:
repos = [repo]
return repos
self.tdb.item_repos = item_repos
self.odb.item_repos = item_repos
class ItemByRepoTestCase(testcase.TestCase):
testdb = TestDB()
def testHasRepository(self):
assert self.testdb.tdb.has_repo("pardus-2007")
assert self.testdb.tdb.has_repo("contrib-2007")
assert not self.testdb.tdb.has_repo("hedehodo")
def testHasItem(self):
assert self.testdb.tdb.has_item("kdiff3", "contrib-2007")
assert not self.testdb.tdb.has_item("kdiff3", "pardus-2007")
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("kmess") == "contrib-2007"
def testGetItemAndRepository(self):
pkg, repo = self.testdb.tdb.get_item_repo("acpica")
assert pkg == "package acpica"
assert repo == "pardus-2007"
pkg, repo = self.testdb.tdb.get_item_repo("kmess")
assert pkg == "package kmess"
assert repo == "contrib-2007"
def testItemRepos(self):
db = pisi.db.itembyrepo.ItemByRepo({})
assert db.item_repos("caracal") == ["caracal"]
# repos were created by testcase.py
assert db.item_repos() == ['pardus-2007', 'contrib-2007', 'pardus-2007-src']
def testGetItem(self):
assert self.testdb.tdb.get_item("acpica") == "package acpica"
assert self.testdb.tdb.get_item("kmess") == "package kmess"
def testGetItemOfRepository(self):
assert self.testdb.tdb.get_item("acpica", "pardus-2007") == "package acpica"
assert self.testdb.tdb.get_item("kmess", "contrib-2007") == "package kmess"
def testGetItemKeys(self):
assert set(self.testdb.tdb.get_item_keys("pardus-2007")) == set(["aggdraw", "acpica"])
assert set(self.testdb.tdb.get_item_keys("contrib-2007")) == set(["kdiff3", "kmess"])
assert set(self.testdb.tdb.get_item_keys()) == set(["kdiff3", "kmess", "aggdraw", "acpica"])
def testGetListItem(self):
assert set(self.testdb.odb.get_list_item("pardus-2007")) == set(['rar', 'wengophone'])
assert set(self.testdb.odb.get_list_item("contrib-2007")) == set(['xara'])
assert set(self.testdb.odb.get_list_item()) == set(['rar', 'xara', 'wengophone'])
+41
View File
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import unittest
import pisi.db.lazydb as lazydb
class TestDB(lazydb.LazyDB):
def init(self):
self.testfield = True
def getTestField(self):
return self.testfield
class LazyDBTestCase(unittest.TestCase):
def testDatabaseMethodForcingInit(self):
db = TestDB()
db.getTestField()
assert db.__dict__.has_key("testfield")
del TestDB._the_instance
def testDatabaseWithoutInit(self):
db = TestDB()
assert not db.__dict__.has_key("testfield")
del TestDB._the_instance
def testSingletonBehaviour(self):
db = TestDB()
db2 = TestDB()
assert id(db) == id(db2)
+76
View File
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import testcase
import pisi
class PackageDBTestCase(testcase.TestCase):
packagedb = pisi.db.packagedb.PackageDB()
def testGetPackage(self):
pkg = self.packagedb.get_package("ncftp", "pardus-2007")
assert pkg.name == "ncftp"
pkg = self.packagedb.get_package("lynx", "contrib-2007")
assert pkg.name == "lynx"
pkg = self.packagedb.get_package("cpulimit")
assert pkg.name == "cpulimit"
def testHasPackage(self):
assert self.packagedb.has_package("ncftp", "pardus-2007")
assert not self.packagedb.has_package("ncftp", "contrib-2007")
assert self.packagedb.has_package("lynx")
def testGetVersion(self):
version, release, build = self.packagedb.get_version("lynx", "contrib-2007")
assert version == "0.3"
assert release == "1"
def testWhichRepo(self):
assert self.packagedb.which_repo("lynx") == "contrib-2007"
def testGetPackageAndRepository(self):
pkg, repo = self.packagedb.get_package_repo("cpulimit")
assert pkg.name == "cpulimit"
assert repo == "contrib-2007"
def testGetObsoletes(self):
assert set(self.packagedb.get_obsoletes("pardus-2007")) == set(["wengophone", "rar"])
assert set(self.packagedb.get_obsoletes("contrib-2007")) == set(["xara"])
assert set(self.packagedb.get_obsoletes()) == set(["wengophone", "rar", "xara"])
def testGetReverseDependencies(self):
pkg, dep = self.packagedb.get_rev_deps("openssl")[0]
assert pkg == "curl"
assert str(dep) == "openssl"
def testGetReplaces(self):
# FIXME: update createrepo.py to generate replaces
assert not self.packagedb.get_replaces()
def testListPackages(self):
assert set(self.packagedb.list_packages("pardus-2007")) == set(['nfdump', 'ethtool', 'ncftp',
'libidn', 'zlib', 'db4', 'openssl',
'jpeg', 'pam', 'shadow', 'bogofilter',
'curl', 'gsl', 'bash', 'cracklib'])
assert set(self.packagedb.list_packages("contrib-2007")) == set(['libpcap', 'ctorrent', 'lft', 'lynx',
'iat', 'cpulimit', 'rpl'])
def testSearchPackage(self):
packages = self.packagedb.search_package(["bogo", "filter"])
packages = ["bogofilter"]
packages = self.packagedb.search_package(["cpu", "limit"], repo="contrib-2007")
packages = ["cpulimit"]
+62
View File
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import testcase
import pisi
class RepoDBTestCase(testcase.TestCase):
repodb = pisi.db.repodb.RepoDB()
def testAddRemoveRepo(self):
assert "contrib-2007-src" not in self.repodb.list_repos()
repo = pisi.db.repodb.Repo(pisi.uri.URI("repos/contrib-2007/pisi-index.xml.bz2"))
self.repodb.add_repo("contrib-2007-src", repo)
assert "contrib-2007-src" in self.repodb.list_repos()
self.repodb.remove_repo("contrib-2007-src")
assert "contrib-2007" in self.repodb.list_repos()
assert "pardus-2007" in self.repodb.list_repos()
assert "contrib-2007-src" not in self.repodb.list_repos()
def testAddRemoveCycle(self):
for r in range(30):
assert "test-repo" not in self.repodb.list_repos()
repo = pisi.db.repodb.Repo(pisi.uri.URI("http://test-repo/pisi-index.xml.bz2"))
self.repodb.add_repo("test-repo", repo)
assert "test-repo" in self.repodb.list_repos()
self.repodb.remove_repo("test-repo")
assert "test-repo" not in self.repodb.list_repos()
def testListRepos(self):
assert set(self.repodb.list_repos()) == set(['pardus-2007', 'contrib-2007', 'pardus-2007-src'])
def testGetSourceRepos(self):
assert set(self.repodb.get_source_repos()) == set(['pardus-2007-src'])
def testGetBinaryRepos(self):
assert set(self.repodb.get_binary_repos()) == set(['pardus-2007', 'contrib-2007'])
def testGetRepo(self):
repo = self.repodb.get_repo("pardus-2007")
uri = repo.indexuri
assert uri.get_uri() == "repos/pardus-2007-bin/pisi-index.xml.bz2"
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']
repoorder.remove("test-repo")
assert repoorder.get_order() == ['pardus-2007', 'contrib-2007', 'pardus-2007-src']
+58
View File
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2007, 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
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import testcase
import pisi
class SourceDBTestCase(testcase.TestCase):
sourcedb = pisi.db.sourcedb.SourceDB()
def testListSources(self):
assert set(self.sourcedb.list_sources()) == set(['ethtool', 'nfdump', 'shadow', 'libidn',
'zlib', 'db4', 'openssl', 'jpeg', 'gsl',
'curl', 'bogofilter', 'ncftp', 'pam',
'bash', 'cracklib'])
def testHasSpec(self):
assert self.sourcedb.has_spec("ethtool")
assert not self.sourcedb.has_spec("hedehodo")
def testGetSpec(self):
spec = self.sourcedb.get_spec("ethtool")
assert spec.source.name == "ethtool"
assert spec.source.partOf == "applications.network"
def testGetSpecOfRepository(self):
spec = self.sourcedb.get_spec("ethtool", "pardus-2007-src")
assert spec.source.name == "ethtool"
assert spec.source.partOf == "applications.network"
def testGetSpecAndRepository(self):
spec, repo = self.sourcedb.get_spec_repo("ethtool")
assert spec.source.name == "ethtool"
assert spec.source.partOf == "applications.network"
assert repo == "pardus-2007-src"
def testGetSourceFromPackage(self):
# FIXME: Add multi package from source to createrepo.py
pkg = self.sourcedb.pkgtosrc("cracklib")
assert pkg == "cracklib"
def testSearchPackage(self):
packages = self.sourcedb.search_spec(["open", "ssl"])
assert set(["openssl"]) == set(packages)
packages = self.sourcedb.search_spec(["bogo", "filter"], repo="pardus-2007-src")
assert set(["bogofilter"]) == set(packages)
+21
View File
@@ -0,0 +1,21 @@
import unittest
import pisi
class TestCase(unittest.TestCase):
def setUp(self):
options = pisi.config.Options()
options.ignore_build_no = False
options.destdir = 'repos/tmp'
pisi.api.set_options(options)
pisi.api.set_comar(False)
if not pisi.api.list_repos():
pisi.api.add_repo("pardus-2007", "repos/pardus-2007-bin/pisi-index.xml.bz2")
pisi.api.add_repo("contrib-2007", "repos/contrib-2007-bin/pisi-index.xml.bz2")
pisi.api.add_repo("pardus-2007-src", "repos/pardus-2007/pisi-index.xml.bz2")
pisi.api.update_repo("pardus-2007")
pisi.api.update_repo("contrib-2007")
pisi.api.update_repo("pardus-2007-src")