Change to project/trunk,tags,branches style
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
|
||||
PiSi UnitTests
|
||||
##############
|
||||
|
||||
Before running unittests you need to first go to repos directory and
|
||||
create test repositories.
|
||||
|
||||
>>> pisi@pardus tests/repos# python createrepos.py
|
||||
|
||||
Now you can return to tests folder and run tests.
|
||||
|
||||
>>> pisi@pardus tests # python runtests.py
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import pisi
|
||||
import unittest
|
||||
from pisi import util
|
||||
from pisi import uri
|
||||
from pisi import archive
|
||||
from pisi import sourcearchive
|
||||
from pisi import fetcher
|
||||
from pisi.specfile import SpecFile
|
||||
from os.path import join, exists
|
||||
|
||||
class ArchiveTestCase(unittest.TestCase):
|
||||
|
||||
def testTarUnpack(self):
|
||||
spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml')
|
||||
targetDir = '/tmp/tests'
|
||||
archiv = sourcearchive.SourceArchive(spec, targetDir)
|
||||
archiv.unpack()
|
||||
assert spec.source.archive.type == 'targz'
|
||||
|
||||
|
||||
def testUnpackTarCond(self):
|
||||
spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml')
|
||||
targetDir = '/tmp'
|
||||
archiv = sourcearchive.SourceArchive(spec, targetDir)
|
||||
url = uri.URI(spec.source.archive.uri)
|
||||
filePath = join(pisi.context.config.archives_dir(), url.filename())
|
||||
if util.sha1_file(filePath) != spec.source.archive.sha1sum:
|
||||
fetch = fetcher.Fetcher(spec.source.archive.uri, targetDir)
|
||||
fetch.fetch()
|
||||
assert spec.source.archive.type == 'targz'
|
||||
|
||||
def testZipUnpack(self):
|
||||
spec = SpecFile('repos/pardus-2007/system/base/openssl/pspec.xml')
|
||||
targetDir = '/tmp/tests'
|
||||
archiv = sourcearchive.SourceArchive(spec, targetDir)
|
||||
archiv.fetch()
|
||||
archiv.unpack()
|
||||
assert not exists(targetDir + '/openssl')
|
||||
|
||||
def testMakeZip(self):
|
||||
spec = SpecFile('repos/pardus-2007/system/base/openssl/pspec.xml')
|
||||
targetDir = '/tmp/tests'
|
||||
archiv = sourcearchive.SourceArchive(spec, targetDir)
|
||||
archiv.fetch(interactive = False)
|
||||
archiv.unpack(clean_dir = True)
|
||||
del archiv
|
||||
|
||||
newDir = targetDir + '/newZip'
|
||||
zip = archive.ArchiveZip(newDir, 'zip', 'w')
|
||||
sourceDir = '/tmp/pisi-root'
|
||||
zip.add_to_archive(sourceDir)
|
||||
zip.close()
|
||||
@@ -0,0 +1,59 @@
|
||||
import unittest
|
||||
from pisi.configfile import ConfigurationFile
|
||||
|
||||
class ConfigFileTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.cf = ConfigurationFile('pisi.conf')
|
||||
|
||||
def testGeneralDefaults(self):
|
||||
cf = self.cf
|
||||
self.assertEqual(cf.general.destinationDirectory, cf.general['destinationDirectory'])
|
||||
assert not cf.general.autoclean
|
||||
self.assertEqual(cf.general.http_proxy, cf.general['http_proxy'])
|
||||
assert not cf.general.package_cache
|
||||
|
||||
def testBuildDefaults(self):
|
||||
cf = self.cf
|
||||
self.assertEqual(cf.build.jobs, cf.build['jobs'])
|
||||
assert not cf.build.generateDebug
|
||||
assert not cf.build.enableSandbox
|
||||
self.assertEqual(cf.build.compressionlevel, cf.build['compressionlevel'])
|
||||
self.assertEqual(cf.build.fallback, cf.build['fallback'])
|
||||
|
||||
def testDirectoriesDefaults(self):
|
||||
cf = self.cf
|
||||
self.assertEqual(cf.dirs.lib_dir, cf.dirs['lib_dir'])
|
||||
self.assertEqual(cf.dirs.index_dir, cf.dirs['index_dir'])
|
||||
|
||||
def testConfigurationSection(self):
|
||||
cf = self.cf
|
||||
if not cf.general:
|
||||
self.fail()
|
||||
if not cf.build:
|
||||
self.fail()
|
||||
if not cf.dirs:
|
||||
self.fail()
|
||||
|
||||
def testPisiConfValues(self):
|
||||
cf = self.cf
|
||||
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')
|
||||
|
||||
def testValuesExists(self):
|
||||
cf = self.cf
|
||||
assert cf.general.distribution
|
||||
assert not cf.general.targetDirectory
|
||||
assert cf.build.cxxflags
|
||||
assert not cf.build.configurationlevel
|
||||
assert cf.dirs.qt_dir
|
||||
assert not cf.dirs.cache_dir
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import unittest
|
||||
import pisi
|
||||
import pisi.relation
|
||||
import pisi.conflict
|
||||
|
||||
class ConflictTestCase(unittest.TestCase):
|
||||
def testInstalledPackageConflicts(self):
|
||||
pisi.api.install(["ethtool"])
|
||||
relation = pisi.relation.Relation()
|
||||
relation.package = "ethtool"
|
||||
relation.version = "6"
|
||||
relation.release = "1"
|
||||
|
||||
confinfo = pisi.conflict.Conflict(relation)
|
||||
assert not pisi.conflict.installed_package_conflicts(confinfo)
|
||||
|
||||
def testCalculateConflicts(self):
|
||||
packagedb = pisi.db.packagedb.PackageDB()
|
||||
packages = ["ethtool", "zlib", "ctorrent"]
|
||||
assert pisi.conflict.calculate_conflicts(packages, packagedb)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import unittest
|
||||
import pisi.constants
|
||||
import pisi.context as ctx
|
||||
|
||||
class ConstantTestCase(unittest.TestCase):
|
||||
|
||||
def testConstants(self):
|
||||
constants = ctx.const
|
||||
constDict = {"actions": "actions.py", "setup":"setup","metadata":"metadata.xml"}
|
||||
|
||||
for i in constDict.keys():
|
||||
if hasattr(constants,i):
|
||||
value = getattr(constants,i)
|
||||
self.assertEqual(value, constDict[i])
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
*.pyc
|
||||
@@ -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.
|
||||
#
|
||||
@@ -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
|
||||
@@ -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"])
|
||||
@@ -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)
|
||||
@@ -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'])
|
||||
@@ -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)
|
||||
|
||||
@@ -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"]
|
||||
@@ -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']
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import unittest
|
||||
import pisi.relation
|
||||
import pisi.dependency
|
||||
|
||||
class DependencyTestCase(unittest.TestCase):
|
||||
|
||||
def testDictSatisfiesDep(self):
|
||||
pisi.api.install(["ethtool"])
|
||||
relation = pisi.relation.Relation()
|
||||
relation.package = "ethtool"
|
||||
|
||||
pisi.api.install(["zlib"])
|
||||
rel = pisi.relation.Relation()
|
||||
rel.package = "zlib"
|
||||
|
||||
depinfo = pisi.dependency.Dependency(relation)
|
||||
dictionary = {"ethtool": [" "],"zlib":["a","b"],"ctorrent":["c"]}
|
||||
assert not pisi.dependency.dict_satisfies_dep(dictionary,depinfo)
|
||||
depinf = pisi.dependency.Dependency(rel)
|
||||
assert not pisi.dependency.dict_satisfies_dep(dictionary,depinf)
|
||||
|
||||
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)
|
||||
|
||||
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")
|
||||
@@ -0,0 +1,35 @@
|
||||
import unittest
|
||||
import os
|
||||
import base64
|
||||
import pisi.context as ctx
|
||||
import pisi.api
|
||||
from pisi.specfile import SpecFile
|
||||
from pisi.fetcher import Fetcher
|
||||
from pisi import util
|
||||
from pisi import uri
|
||||
|
||||
class FetchTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
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.set_auth_info(("user", "pass"))
|
||||
self.destpath = ctx.config.archives_dir()
|
||||
self.fetch = Fetcher(self.url, self.destpath)
|
||||
|
||||
def testFetch(self):
|
||||
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)
|
||||
os.remove(fetchedFile)
|
||||
|
||||
def testFetcherFunctions(self):
|
||||
enc = base64.encodestring('%s:%s' % self.url.auth_info())
|
||||
self.assertEqual(self.fetch._get_http_headers(),(('Authorization', 'Basic %s' % enc),))
|
||||
assert not self.fetch._get_ftp_headers()
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import unittest
|
||||
import pisi.files
|
||||
|
||||
class FilesTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
unittest.TestCase.setUp(self)
|
||||
|
||||
def testFileInfo(self):
|
||||
file1 = pisi.files.FileInfo(path = '/usr/bin/acpi')
|
||||
file1.type = 'init'
|
||||
file1.size = '30'
|
||||
|
||||
file2 = pisi.files.FileInfo(path = '/sbin/blkid', type = 'ctors', size = '8')
|
||||
|
||||
def testFiles(self):
|
||||
self.files = pisi.files.Files()
|
||||
self.files.read('repos/pardus-2007/system/base/curl/pspec.xml')
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import unittest
|
||||
from pisi.specfile import SpecFile
|
||||
from pisi import uri
|
||||
from pisi.file import File
|
||||
|
||||
class FileTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
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'))
|
||||
|
||||
def testChooseMethod(self):
|
||||
compress = File('repos/contrib-2007/pisi-index.xml.bz2', File.read)
|
||||
self.assert_(File.choose_method('pisi.conf', compress))
|
||||
|
||||
def testDecompress(self):
|
||||
localfile = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
|
||||
compress = File('repos/contrib-2007/pisi-index.xml.bz2', File.read)
|
||||
self.assert_(File.decompress(localfile,compress))
|
||||
|
||||
def testLocalFile(self):
|
||||
f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read)
|
||||
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)
|
||||
r = f.readlines()
|
||||
assert (len(r) > 0)
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import unittest
|
||||
import os
|
||||
import pisi
|
||||
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.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))
|
||||
|
||||
def testHasVertex(self):
|
||||
assert not self.g0.has_vertex(5)
|
||||
assert not self.g1.has_vertex(1)
|
||||
|
||||
def testHasEdge(self):
|
||||
assert not self.g0.has_edge(5,6)
|
||||
assert not self.g0.has_edge(3,5)
|
||||
assert not self.g1.has_edge(2,3)
|
||||
|
||||
def testCycle(self):
|
||||
assert 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))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<PISI>
|
||||
|
||||
<Operation type="upgrade" date="2008-01-14" time="15:10">
|
||||
|
||||
<Package operation="upgrade">
|
||||
<Name>gdb</Name>
|
||||
<Before version="6.6" release="8" build="9"/>
|
||||
<After version="6.6" release="9" build="10"/>
|
||||
</Package>
|
||||
|
||||
<Package operation="upgrade">
|
||||
<Name>rsync</Name>
|
||||
<Before version="2.6.9" release="8" build="4"/>
|
||||
<After version="2.6.9" release="12" build="7"/>
|
||||
</Package>
|
||||
|
||||
<!-- In an upgrade operation this package is removed. Probably a conflicted package. -->
|
||||
<Package operation="remove">
|
||||
<Name>hashalot</Name>
|
||||
<Before version="2.3.6" release="20" build="23"/>
|
||||
</Package>
|
||||
|
||||
<!-- In an upgrade operation this package is installed. Must be a new dependency. -->
|
||||
<Package operation="install">
|
||||
<Name>XML-DOM</Name>
|
||||
<After version="1.44" release="1" build="1"/>
|
||||
</Package>
|
||||
|
||||
</Operation>
|
||||
|
||||
</PISI>
|
||||
@@ -0,0 +1,17 @@
|
||||
<PISI>
|
||||
|
||||
<Operation type="remove" date="2008-01-16" time="15:00">
|
||||
|
||||
<Package operation="remove">
|
||||
<Name>gdb</Name>
|
||||
<Before version="6.6" release="8" build="9"/>
|
||||
</Package>
|
||||
|
||||
<Package operation="remove">
|
||||
<Name>rsync</Name>
|
||||
<Before version="2.6.9" release="8" build="4"/>
|
||||
</Package>
|
||||
|
||||
</Operation>
|
||||
|
||||
</PISI>
|
||||
@@ -0,0 +1,36 @@
|
||||
<PISI>
|
||||
|
||||
<Operation type="install" date="2008-01-11" time="15:20">
|
||||
|
||||
<Package operation="install">
|
||||
<Name>gdb</Name>
|
||||
<After version="6.6" release="9" build="10"/>
|
||||
</Package>
|
||||
|
||||
<!-- This is a reinstalled package. -->
|
||||
<Package operation="reinstall">
|
||||
<Name>rsync</Name>
|
||||
<Before version="2.6.9" release="8" build="4"/>
|
||||
<After version="2.6.9" release="8" build="4"/>
|
||||
</Package>
|
||||
|
||||
<Package operation="downgrade">
|
||||
<Name>apackage</Name>
|
||||
<Before version="1.3" release="12" build="9"/>
|
||||
<After version="1.3" release="6" build="2"/>
|
||||
</Package>
|
||||
|
||||
<Package operation="install">
|
||||
<Name>xyz</Name>
|
||||
<After version="2.6.9" release="12" build="7"/>
|
||||
</Package>
|
||||
|
||||
<!-- In an install operation this package is removed. Probably a conflicted package. -->
|
||||
<Package operation="remove">
|
||||
<Name>hashalot</Name>
|
||||
<Before version="2.3.6" release="20" build="23"/>
|
||||
</Package>
|
||||
|
||||
</Operation>
|
||||
|
||||
</PISI>
|
||||
@@ -0,0 +1,22 @@
|
||||
<PISI>
|
||||
|
||||
<Operation type="snapshot" date="2008-01-14" time="15:28">
|
||||
|
||||
<Package operation="snapshot">
|
||||
<Name>readline</Name>
|
||||
<Before version="2.3.6" release="20" build="23"/>
|
||||
</Package>
|
||||
|
||||
<Package operation="snapshot">
|
||||
<Name>gdb</Name>
|
||||
<Before version="6.6" release="8" build="9"/>
|
||||
</Package>
|
||||
|
||||
<Package operation="snapshot">
|
||||
<Name>rsync</Name>
|
||||
<Before version="2.6.9" release="8" build="4"/>
|
||||
</Package>
|
||||
|
||||
</Operation>
|
||||
|
||||
</PISI>
|
||||
@@ -0,0 +1,26 @@
|
||||
import unittest
|
||||
import pisi.relation
|
||||
|
||||
class HistoryTestCase(unittest.TestCase):
|
||||
|
||||
def testCreate(self):
|
||||
history = pisi.history.History()
|
||||
operation = 'upgrade'
|
||||
history.create(operation)
|
||||
history.create('install')
|
||||
history.create('snapshot')
|
||||
|
||||
def testGetLatest(self):
|
||||
history = pisi.history.History()
|
||||
history.read('history/001_upgrade.xml')
|
||||
assert not '099' == history._get_latest()
|
||||
|
||||
history.read('history/002_remove.xml')
|
||||
assert not '099' == history._get_latest()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" ?>
|
||||
<PISI>
|
||||
<Source>
|
||||
<Name>
|
||||
popt
|
||||
</Name>
|
||||
<Packager>
|
||||
<Name>
|
||||
Kırmızı kafalar
|
||||
</Name>
|
||||
<Email>
|
||||
hotmail@redhat.com
|
||||
</Email>
|
||||
</Packager>
|
||||
</Source>
|
||||
<Package>
|
||||
<Name>
|
||||
popt-libs
|
||||
</Name>
|
||||
<Summary>
|
||||
Command line option parsing library
|
||||
</Summary>
|
||||
<Description>
|
||||
library files for popt
|
||||
</Description>
|
||||
<License>
|
||||
As-Is
|
||||
</License>
|
||||
<IsA>
|
||||
library:util:optparser
|
||||
</IsA>
|
||||
<PartOf>
|
||||
rpm:archive
|
||||
</PartOf>
|
||||
<RuntimeDependencies>
|
||||
<Dependency>
|
||||
gettext
|
||||
</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<Files>
|
||||
<Path fileType="sharedLib">
|
||||
/usr/lib
|
||||
</Path>
|
||||
<Path fileType="doc">
|
||||
/usr/share/doc
|
||||
</Path>
|
||||
<Path fileType="doc">
|
||||
/usr/share/man
|
||||
</Path>
|
||||
<Path fileType="localedata">
|
||||
/usr/share/locale
|
||||
</Path>
|
||||
<Path fileType="header">
|
||||
/usr/include/popt.h
|
||||
</Path>
|
||||
</Files>
|
||||
<History>
|
||||
<Update release="3">
|
||||
<Date>2005-06-14</Date>
|
||||
<Version>1.7</Version>
|
||||
</Update>
|
||||
<Update release="2">
|
||||
<Date>2005-06-10</Date>
|
||||
<Version>1.7</Version>
|
||||
</Update>
|
||||
<Update release="3">
|
||||
<Date>2005-05-05</Date>
|
||||
<Version>1.7</Version>
|
||||
</Update>
|
||||
</History>
|
||||
<Build>
|
||||
0
|
||||
</Build>
|
||||
<Distribution>
|
||||
Pardus
|
||||
</Distribution>
|
||||
<DistributionRelease>
|
||||
0.1
|
||||
</DistributionRelease>
|
||||
<Architecture>
|
||||
Any
|
||||
</Architecture>
|
||||
<InstalledSize>
|
||||
149691
|
||||
</InstalledSize>
|
||||
</Package>
|
||||
</PISI>
|
||||
@@ -0,0 +1,27 @@
|
||||
import unittest
|
||||
import os
|
||||
|
||||
from pisi import metadata
|
||||
from pisi import util
|
||||
|
||||
class MetadataTestCase(unittest.TestCase):
|
||||
|
||||
def testRead(self):
|
||||
md = metadata.MetaData()
|
||||
md.read("metadata.xml")
|
||||
self.assertEqual(md.package.license,["As-Is"])
|
||||
self.assertEqual(md.package.version,"1.7")
|
||||
self.assertEqual(md.package.installedSize,149691)
|
||||
return md
|
||||
|
||||
def testVerify(self):
|
||||
md = self.testRead()
|
||||
if md.errors():
|
||||
self.fail()
|
||||
|
||||
def testWrite(self):
|
||||
md = self.testRead()
|
||||
md.write("/tmp/metadata-write.xml")
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
apache http://www.eu.apache.org/dist/
|
||||
cpan http://search.cpan.org/CPAN/
|
||||
cpan http://cpan.ulak.net.tr/
|
||||
gnu http://ftp.gnu.org/gnu/
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2008, 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
|
||||
|
||||
from pisi.mirrors import Mirrors
|
||||
|
||||
class MirrorsTestCase(unittest.TestCase):
|
||||
def testGetMirrors(self):
|
||||
mirrors = Mirrors("mirrors.conf")
|
||||
assert ["http://www.eu.apache.org/dist/"] == mirrors.get_mirrors("apache")
|
||||
assert ['http://search.cpan.org/CPAN/', 'http://cpan.ulak.net.tr/'] == mirrors.get_mirrors("cpan")
|
||||
assert ["http://ftp.gnu.org/gnu/"] == mirrors.get_mirrors("gnu")
|
||||
@@ -0,0 +1,45 @@
|
||||
import unittest
|
||||
import os
|
||||
|
||||
from pisi import util
|
||||
from pisi import package
|
||||
import pisi.context as ctx
|
||||
|
||||
class PackageTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
unittest.TestCase.setUp(self)
|
||||
self.pkgName = util.package_name('test','7.1','2',3)
|
||||
|
||||
def testAddPackage(self):
|
||||
cur = os.getcwd()
|
||||
tmp = ctx.config.tmp_dir()
|
||||
test = os.path.join(cur, 'history')
|
||||
pkg_path = os.path.join(tmp, self.pkgName)
|
||||
pkg = package.Package(pkg_path, "w")
|
||||
|
||||
os.chdir(test)
|
||||
pkg.add_to_package('002_remove.xml')
|
||||
pkg.add_to_package('003_install.xml')
|
||||
os.chdir(cur)
|
||||
pkg.close()
|
||||
|
||||
pkg = package.Package(pkg_path)
|
||||
pkg.extract_file('002_remove.xml', cur)
|
||||
if os.path.exists('files.xml'):
|
||||
self.fail("Package add error")
|
||||
|
||||
os.remove('002_remove.xml')
|
||||
os.remove(pkg_path)
|
||||
|
||||
def testExtractFile(self):
|
||||
cur = os.getcwd()
|
||||
tmp = ctx.config.tmp_dir()
|
||||
pkg_path = os.path.join(tmp, self.pkgName)
|
||||
pkg = package.Package(pkg_path,"w")
|
||||
pkg.extract_file("files.xml",cur)
|
||||
if os.path.exists("files.xml"):
|
||||
self.fail("File extract error")
|
||||
pkg.extract_pisi_files("002_remove.xml")
|
||||
if os.path.exists("002_remove.xml"):
|
||||
self.fail("Pisi files extract error")
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
import unittest
|
||||
import pisi.relation
|
||||
|
||||
class RelationTestCase(unittest.TestCase):
|
||||
def testInstalledPackageSatisfies(self):
|
||||
pisi.api.install(["ethtool"])
|
||||
relation = pisi.relation.Relation()
|
||||
|
||||
relation.package = "ethtool"
|
||||
# Test version = X
|
||||
relation.version = "6"
|
||||
assert pisi.relation.installed_package_satisfies(relation)
|
||||
relation.version = None
|
||||
|
||||
# Test versionFrom = X
|
||||
relation.versionFrom = "3"
|
||||
assert pisi.relation.installed_package_satisfies(relation)
|
||||
relation.versionFrom = "8"
|
||||
assert not pisi.relation.installed_package_satisfies(relation)
|
||||
relation.versionFrom = None
|
||||
|
||||
#Test versionTo = X
|
||||
relation.versionTo = "8"
|
||||
assert pisi.relation.installed_package_satisfies(relation)
|
||||
relation.versionTo = "3"
|
||||
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 = None
|
||||
|
||||
#test releaseFrom = X
|
||||
relation.releaseFrom = "1"
|
||||
assert pisi.relation.installed_package_satisfies(relation)
|
||||
relation.releaseFrom = "7"
|
||||
assert not pisi.relation.installed_package_satisfies(relation)
|
||||
relation.releaseFrom = None
|
||||
|
||||
#test releaseTo = X
|
||||
relation.releaseTo = "7"
|
||||
assert pisi.relation.installed_package_satisfies(relation)
|
||||
relation.releaseTo = "1"
|
||||
assert not pisi.relation.installed_package_satisfies(relation)
|
||||
relation.releaseTo = None
|
||||
|
||||
pisi.api.remove(["ethtool"])
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import unittest
|
||||
import pisi.replace
|
||||
import pisi.relation
|
||||
|
||||
class ReplaceTestCase(unittest.TestCase):
|
||||
def testInstalledPackageReplaced(self):
|
||||
pisi.api.install(["ethtool"])
|
||||
relation = pisi.relation.Relation()
|
||||
relation.package = "ethtool"
|
||||
relation.version = "6"
|
||||
relation.release = "1"
|
||||
|
||||
replace = pisi.replace.Replace(relation)
|
||||
replace.package = "zlib"
|
||||
self.assert_(pisi.replace.installed_package_replaced(replace))
|
||||
repinfo = pisi.replace.Replace(relation)
|
||||
repinfo.package = "ctorrent"
|
||||
self.assert_(pisi.replace.installed_package_replaced(repinfo))
|
||||
|
||||
pisi.api.remove(["ethtool"])
|
||||
Executable
+263
@@ -0,0 +1,263 @@
|
||||
#!/usr/bin/python
|
||||
# -*- 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 os
|
||||
import shutil
|
||||
import time
|
||||
|
||||
pspecTemplate = """<?xml version="1.0" ?>
|
||||
<!DOCTYPE PISI SYSTEM "http://www.pardus.org.tr/projeler/pisi/pisi-spec.dtd">
|
||||
<PISI>
|
||||
<Source>
|
||||
<Name>%(package)s</Name>
|
||||
<Homepage>%(homepage)s</Homepage>
|
||||
<Packager>
|
||||
<Name>%(packager_name)s</Name>
|
||||
<Email>%(packager_email)s</Email>
|
||||
</Packager>
|
||||
<License>GPL-2</License>
|
||||
<IsA>app:gui</IsA>
|
||||
<Summary>%(summary)s</Summary>
|
||||
<Description>%(description)s</Description>
|
||||
<Archive sha1sum="%(sha1sum)s" type="targz">%(archive)s</Archive>
|
||||
</Source>
|
||||
|
||||
<Package>
|
||||
<Name>%(package)s</Name>
|
||||
<RuntimeDependencies>
|
||||
%(runtimedeps)s
|
||||
</RuntimeDependencies>
|
||||
<Files>
|
||||
<Path fileType="data">/usr/bin</Path>
|
||||
</Files>
|
||||
</Package>
|
||||
|
||||
<History>
|
||||
<Update release="1">
|
||||
<Date>%(date)s</Date>
|
||||
<Version>0.3</Version>
|
||||
<Comment>First release</Comment>
|
||||
<Name>%(packager_name)s</Name>
|
||||
<Email>%(packager_email)s</Email>
|
||||
</Update>
|
||||
</History>
|
||||
</PISI>
|
||||
"""
|
||||
|
||||
componentTemplate = """
|
||||
<PISI>
|
||||
<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>
|
||||
<Packager>
|
||||
<Name>Joe Packager</Name>
|
||||
<Email>joe@pardus.org.tr</Email>
|
||||
</Packager>
|
||||
</PISI>
|
||||
"""
|
||||
|
||||
actionsTemplate = """
|
||||
from pisi.actionsapi import pisitools
|
||||
|
||||
WorkDir = "skeleton"
|
||||
|
||||
def install():
|
||||
pisitools.dobin("skeleton.py")
|
||||
pisitools.rename("/usr/bin/skeleton.py", "%s")
|
||||
"""
|
||||
|
||||
distributionTemplate = """
|
||||
<PISI>
|
||||
<SourceName>%(sourcename)s</SourceName>
|
||||
<Version>1.1</Version>
|
||||
<Description xml:lang="tr">%(description)s</Description>
|
||||
<Type>Core</Type>
|
||||
<Obsoletes>
|
||||
%(obsoletes)s
|
||||
</Obsoletes>
|
||||
</PISI>
|
||||
"""
|
||||
|
||||
class Component:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def get_comp_template(self, subcomp):
|
||||
return componentTemplate % {"name":subcomp,
|
||||
"local_name":subcomp,
|
||||
"summary":subcomp,
|
||||
"description":subcomp}
|
||||
|
||||
def get_comp_path(self):
|
||||
return "/".join(self.name.split("."))
|
||||
|
||||
def create(self):
|
||||
component_path = self.get_comp_path()
|
||||
if not os.path.exists(component_path):
|
||||
os.makedirs(component_path)
|
||||
|
||||
cur_dir = os.getcwd()
|
||||
cur_comp = ''
|
||||
for subcomp in self.name.split("."):
|
||||
os.chdir(subcomp)
|
||||
|
||||
if not cur_comp:
|
||||
cur_comp = subcomp
|
||||
else:
|
||||
cur_comp = ".".join([cur_comp, subcomp])
|
||||
|
||||
open("component.xml", "w").write(self.get_comp_template(cur_comp))
|
||||
os.chdir(cur_dir)
|
||||
|
||||
class Package:
|
||||
|
||||
def __init__(self, name, partof, deps):
|
||||
self.name = name
|
||||
self.partof = partof
|
||||
self.deps = deps
|
||||
self.component = Component(self.partof)
|
||||
|
||||
def get_spec_template(self):
|
||||
package = self.name
|
||||
homepage = "www.pardus.org.tr"
|
||||
packager_name = "Joe Packager"
|
||||
packager_email = "joe@pardus.org.tr"
|
||||
summary = "%s is a very useful package" % self.name
|
||||
description = "%s is a very useful package that is known for its usefulness." % self.name
|
||||
sha1sum = "cc64dfa6e068fe1f6fb68a635878b1ea21acfac7"
|
||||
archive = "http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz"
|
||||
date = time.strftime("%Y-%m-%d")
|
||||
partof = self.partof
|
||||
|
||||
runtimedeps = ""
|
||||
for dep in self.deps:
|
||||
runtimedeps += " <Dependency>%s</Dependency>\n" % dep
|
||||
|
||||
return pspecTemplate % locals()
|
||||
|
||||
def create(self):
|
||||
self.component.create()
|
||||
cur_dir = os.getcwd()
|
||||
os.chdir(self.component.get_comp_path())
|
||||
os.makedirs(self.name)
|
||||
os.chdir(self.name)
|
||||
open("pspec.xml", "w").write(self.get_spec_template())
|
||||
open("actions.py", "w").write(actionsTemplate % self.name)
|
||||
os.chdir(cur_dir)
|
||||
|
||||
class PackageFactory:
|
||||
def getPackage(self, name, runtimeDeps = [], component = "system.base"):
|
||||
return Package(name, component, runtimeDeps)
|
||||
|
||||
def getPackageBundle(self, component, *packages):
|
||||
pkgs = []
|
||||
for pkg in packages:
|
||||
pkgs.append(Package(pkg, component, []))
|
||||
return pkgs
|
||||
|
||||
class Repository:
|
||||
def __init__(self, name, packages, obsoletes):
|
||||
self.name = name
|
||||
self.packages = packages
|
||||
self.obsoletes = obsoletes
|
||||
|
||||
def get_dist_template(self):
|
||||
obsoletes = ""
|
||||
for obs in self.obsoletes:
|
||||
obsoletes += " <Package>%s</Package>\n" % obs
|
||||
|
||||
return distributionTemplate % {"sourcename":self.name,
|
||||
"description":self.name,
|
||||
"obsoletes":obsoletes}
|
||||
|
||||
def create(self):
|
||||
cur_dir = os.getcwd()
|
||||
os.makedirs(self.name)
|
||||
os.chdir(self.name)
|
||||
open("distribution.xml", "w").write(self.get_dist_template())
|
||||
|
||||
for pkg in self.packages:
|
||||
pkg.create()
|
||||
|
||||
os.chdir(cur_dir)
|
||||
|
||||
class Pardus2007Repo(Repository):
|
||||
def __init__(self):
|
||||
Repository.__init__(self, "pardus-2007", [], ["wengophone", "rar"])
|
||||
|
||||
def create(self):
|
||||
|
||||
pf = PackageFactory()
|
||||
|
||||
self.packages = [
|
||||
# system.base
|
||||
pf.getPackage("bash"),
|
||||
pf.getPackage("curl", ["libidn", "zlib", "openssl"]),
|
||||
pf.getPackage("shadow", ["db4","pam", "cracklib"]),
|
||||
pf.getPackage("jpeg"),
|
||||
|
||||
# applications.network
|
||||
pf.getPackage("ncftp", [], "applications.network"),
|
||||
pf.getPackage("bogofilter", ["gsl"], "applications.network"),
|
||||
pf.getPackage("gsl", [], "applications.network"),
|
||||
]
|
||||
|
||||
# system.base
|
||||
self.packages.extend(pf.getPackageBundle("system.base", "libidn", "zlib", "openssl", "db4", "pam", "cracklib"))
|
||||
|
||||
# applications.network
|
||||
self.packages.extend(pf.getPackageBundle("applications.network", "ethtool", "nfdump"))
|
||||
|
||||
Repository.create(self)
|
||||
|
||||
class Contrib2007Repo(Repository):
|
||||
def __init__(self):
|
||||
Repository.__init__(self, "contrib-2007", [], ["xara"])
|
||||
|
||||
def create(self):
|
||||
|
||||
pf = PackageFactory()
|
||||
|
||||
self.packages = [
|
||||
# applications.network
|
||||
pf.getPackage("lynx", [], "applications.network"),
|
||||
pf.getPackage("ctorrent", ["openssl"], "applications.network"),
|
||||
pf.getPackage("lft", ["libpcap"], "applications.network"),
|
||||
pf.getPackage("libpcap", [], "applications.network"),
|
||||
]
|
||||
|
||||
# applications.util
|
||||
self.packages.extend(pf.getPackageBundle("applications.util", "iat", "rpl", "cpulimit"))
|
||||
|
||||
Repository.create(self)
|
||||
|
||||
class BuildFarm:
|
||||
def create_index(self, repo):
|
||||
binrepo = "%s-bin" % repo
|
||||
shutil.copy("%s/distribution.xml" % repo, binrepo)
|
||||
os.system("pisi index %s --skip-signing -o %s/pisi-index.xml" % (repo, repo))
|
||||
os.system("pisi index --skip-sources --skip-signing -o %s/pisi-index.xml %s %s" % (binrepo, binrepo, repo))
|
||||
|
||||
def build(self, repos):
|
||||
for repo in repos:
|
||||
binrepo = "%s-bin" % repo
|
||||
os.mkdir(binrepo)
|
||||
for root, dirs, files in os.walk(repo):
|
||||
if "pspec.xml" in files:
|
||||
os.system("pisi build %s/%s -O %s" % (root, "pspec.xml", binrepo))
|
||||
self.create_index(repo)
|
||||
|
||||
if __name__ == "__main__":
|
||||
Pardus2007Repo().create()
|
||||
Contrib2007Repo().create()
|
||||
BuildFarm().build(["pardus-2007", "contrib-2007"])
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
# -*- 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 database
|
||||
|
||||
from database.repodbtest import RepoDBTestCase
|
||||
from database.packagedbtest import PackageDBTestCase
|
||||
from database.sourcedbtest import SourceDBTestCase
|
||||
from database.installdbtest import InstallDBTestCase
|
||||
from database.componentdbtest import ComponentDBTestCase
|
||||
from database.filesdbtest import FilesDBTestCase
|
||||
from database.lazydbtest import LazyDBTestCase
|
||||
from database.itembyrepotest import ItemByRepoTestCase
|
||||
|
||||
from archivetests import ArchiveTestCase
|
||||
from configfiletest import ConfigFileTestCase
|
||||
from conflicttests import ConflictTestCase
|
||||
from constanttest import ConstantTestCase
|
||||
from dependencytest import DependencyTestCase
|
||||
from fetchtest import FetchTestCase
|
||||
from filetest import FileTestCase
|
||||
from filestest import FilesTestCase
|
||||
from graphtest import GraphTestCase
|
||||
from historytest import HistoryTestCase
|
||||
from metadatatest import MetadataTestCase
|
||||
from mirrorstest import MirrorsTestCase
|
||||
from packagetest import PackageTestCase
|
||||
from relationtest import RelationTestCase
|
||||
from replacetest import ReplaceTestCase
|
||||
from shelltest import ShellTestCase
|
||||
from specfiletests import SpecFileTestCase
|
||||
from srcarchivetest import SourceArchiveTestCase
|
||||
from uritest import UriTestCase
|
||||
from utiltest import UtilTestCase
|
||||
from versiontest import VersionTestCase
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,110 @@
|
||||
import unittest
|
||||
import pisi
|
||||
import pisi.actionsapi
|
||||
import os
|
||||
import shutil
|
||||
|
||||
class ShellTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
from pisi.actionsapi.variables import initVariables
|
||||
unittest.TestCase.setUp(self)
|
||||
initVariables()
|
||||
return
|
||||
|
||||
def testCanAccessFile(self):
|
||||
from pisi.actionsapi.shelltools import can_access_file
|
||||
assert can_access_file('/usr/lib/engines/libaep.so')
|
||||
assert not can_access_file('actionsapi/set.py')
|
||||
|
||||
def testCanAccessDirectory(self):
|
||||
from pisi.actionsapi.shelltools import can_access_directory
|
||||
assert can_access_directory('/boot')
|
||||
assert can_access_directory('/usr/bin')
|
||||
assert not can_access_directory('/tests/mirrors.conf')
|
||||
|
||||
def testMakedirs(self):
|
||||
from pisi.actionsapi.shelltools import makedirs
|
||||
|
||||
makedirs('tests/testdirectory/aDirectory')
|
||||
self.assertEqual(os.path.exists('tests/testdirectory/aDirectory'),True)
|
||||
shutil.rmtree('tests/testdirectory')
|
||||
|
||||
def testEcho(self):
|
||||
from pisi.actionsapi.shelltools import echo
|
||||
|
||||
echo('tests/echo-file','eco subject')
|
||||
self.assertEqual(os.path.exists('tests/echo-file'),True)
|
||||
self.assertEqual(open('tests/echo-file').readlines()[0].strip(), 'eco subject')
|
||||
echo('tests/echo-file', 'subject eco')
|
||||
self.assertEqual(open('tests/echo-file').readlines()[1].strip(), 'subject eco')
|
||||
os.remove('tests/echo-file')
|
||||
|
||||
def testSym(self):
|
||||
from pisi.actionsapi.shelltools import sym
|
||||
|
||||
sym('scenarios/repo','tests/repos')
|
||||
self.assertEqual(os.path.islink('tools'),False)
|
||||
self.assertEqual(os.path.islink('tests/repos'),True)
|
||||
|
||||
def testUnlinkDir(self):
|
||||
from pisi.actionsapi.shelltools import makedirs
|
||||
from pisi.actionsapi.shelltools import sym
|
||||
from pisi.actionsapi.shelltools import unlinkDir
|
||||
|
||||
makedirs('tests/testdirectory/sample')
|
||||
sym('tests/testdirectory/sample','tests/history')
|
||||
self.assertEqual(os.path.islink('tests/history'),True)
|
||||
unlinkDir('tests/testdirectory/sample')
|
||||
self.assertEqual(os.path.islink('tests/testdirectory/sample'),False)
|
||||
|
||||
def testCopy(self):
|
||||
from pisi.actionsapi.shelltools import copy
|
||||
|
||||
copy('/pisi/tests', '/pisi/tests-copy')
|
||||
self.assertEqual(os.path.islink('pisi/tests-copy'),False)
|
||||
|
||||
copy('pisi/tests/scripts/sync-licenses', 'pisi/tests/scripts/sync-licenses-copy')
|
||||
self.assertEqual(os.path.islink('pisi/tests/scripts/sync-licenses-copy'),False)
|
||||
|
||||
def testIsLink(self):
|
||||
from pisi.actionsapi.shelltools import sym
|
||||
from pisi.actionsapi.shelltools import isLink
|
||||
|
||||
sym('tests/database','tests/history')
|
||||
assert isLink('tests/history')
|
||||
assert not isLink('tests/runtests.py')
|
||||
|
||||
def testIsFile(self):
|
||||
from pisi.actionsapi.shelltools import isFile
|
||||
|
||||
assert isFile('/usr/lib/engines/libaep.so')
|
||||
assert not isFile('/tests/database')
|
||||
|
||||
def testIsDirectory(self):
|
||||
from pisi.actionsapi.shelltools import isDirectory
|
||||
|
||||
assert not isDirectory('doc/dependency.pdf')
|
||||
assert isDirectory('/usr/lib')
|
||||
assert isDirectory('/etc/pisi')
|
||||
assert not isDirectory('/tests/shelltest.py')
|
||||
|
||||
def testRealPath(self):
|
||||
from pisi.actionsapi.shelltools import realPath
|
||||
|
||||
assert realPath('doc/dependency.pdf')
|
||||
assert realPath('tests/database/sourcedbtest.py')
|
||||
|
||||
def testBaseName(self):
|
||||
from pisi.actionsapi.shelltools import baseName
|
||||
|
||||
assert 'dependency.pdf' == baseName('doc/dependency.pdf')
|
||||
assert 'Arphic' == baseName('licenses/Arphic')
|
||||
assert not 'Atmel' == baseName('tools/atmel.py')
|
||||
|
||||
def testSystem(self):
|
||||
from pisi.actionsapi.shelltools import system
|
||||
|
||||
self.assertEqual(os.path.exists('tests/systemtest'),False)
|
||||
system('touch tests/systemtest')
|
||||
self.assertEqual(os.path.exists('tests/systemtest'),True)
|
||||
os.remove('tests/systemtest')
|
||||
@@ -0,0 +1,36 @@
|
||||
import unittest
|
||||
import os
|
||||
import pisi.specfile as specfile
|
||||
import pisi.util as util
|
||||
|
||||
class SpecFileTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.spec = specfile.SpecFile()
|
||||
self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml')
|
||||
|
||||
def testGetSourceVersion(self):
|
||||
assert '0.3' == self.spec.getSourceVersion()
|
||||
|
||||
def testGetSourceRelease(self):
|
||||
assert '1' == self.spec.getSourceRelease()
|
||||
|
||||
def testVerify(self):
|
||||
if self.spec.errors():
|
||||
self.fail()
|
||||
|
||||
def testCopy(self):
|
||||
self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml')
|
||||
self.spec.write('repos/pardus-2007/system/base/curl/pspec.xml')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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.unpack()
|
||||
@@ -0,0 +1,42 @@
|
||||
import unittest
|
||||
import os
|
||||
from pisi import uri
|
||||
from pisi.file import File
|
||||
from pisi.specfile import SpecFile
|
||||
|
||||
class UriTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
unittest.TestCase.setUp(self)
|
||||
|
||||
def testSetUri(self):
|
||||
self.spec = SpecFile()
|
||||
self.url = uri.URI(self.spec.source.archive.uri)
|
||||
self.url.set_uri('uri')
|
||||
assert 'uri' == self.url.get_uri()
|
||||
self.url.set_uri('urix')
|
||||
assert 'urix' == self.url.get_uri()
|
||||
|
||||
def testIsLocalFile(self):
|
||||
uri1 = uri.URI()
|
||||
assert not uri1.is_local_file()
|
||||
uri1.set_uri('/usr/local')
|
||||
assert uri1.is_local_file()
|
||||
|
||||
def testIsRemoteFile(self):
|
||||
uri2 = uri.URI()
|
||||
assert uri2.is_remote_file()
|
||||
uri2.set_uri('uri')
|
||||
assert not uri2.is_remote_file()
|
||||
|
||||
def testSchemePath(self):
|
||||
uri3 = uri.URI()
|
||||
uri3.set_uri('/usr/bin')
|
||||
self.assertEqual('file', uri3.scheme())
|
||||
assert '/usr/bin' == uri3.path()
|
||||
|
||||
def testFileName(self):
|
||||
uri4 = uri.URI()
|
||||
uri4.set_uri('/usr/share/aclocal')
|
||||
assert 'aclocal' == uri4.filename()
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import unittest
|
||||
import shutil
|
||||
from pisi.util import *
|
||||
import os
|
||||
|
||||
class UtilTestCase(unittest.TestCase):
|
||||
|
||||
def initialize(self):
|
||||
testcase.testCase.initialize(self, database=False)
|
||||
|
||||
#process related functions
|
||||
def testRunBatch(self):
|
||||
assert (0, '', '') == run_batch('cd')
|
||||
assert (127, '', '/bin/sh: add: command not found\n') == run_batch('add')
|
||||
|
||||
def testRunLogged(self):
|
||||
assert 0 == run_logged('ls')
|
||||
assert 1 == run_logged('rm')
|
||||
|
||||
def testXtermTitle(self):
|
||||
xterm_title('pardus')
|
||||
xterm_title_reset()
|
||||
|
||||
#path processing functions tests
|
||||
def testSplitPath(self):
|
||||
assert ['usr', 'local', 'src'] == splitpath('usr/local/src')
|
||||
assert ['usr', 'lib', 'pardus'] == splitpath('usr/lib/pardus')
|
||||
|
||||
def testSubPath(self):
|
||||
self.assert_(subpath('usr','usr'))
|
||||
self.assert_(subpath('usr','usr/local/src'))
|
||||
self.assert_(not subpath('usr/local','usr'))
|
||||
|
||||
def testRemovePathPrefix(self):
|
||||
pathname = removepathprefix('usr/local', 'usr/local/src')
|
||||
assert 'src' == pathname
|
||||
|
||||
pathname = removepathprefix('usr/local','usr/local/bin')
|
||||
assert not 'bim' == pathname
|
||||
|
||||
def testJoinPath(self):
|
||||
assert 'usr/local/src' == join_path('usr/local','src')
|
||||
assert not 'usr/lib/hal' == join_path('usr','hal')
|
||||
assert 'usr/sbin/lpc' == join_path('usr','sbin/lpc')
|
||||
|
||||
#file/directory related functions tests
|
||||
def testCheckFile(self):
|
||||
assert check_file('/etc/pisi/pisi.conf')
|
||||
assert check_file('/usr/bin/aatest')
|
||||
|
||||
def testCleanDir(self):
|
||||
assert None == clean_dir('usr/lib')
|
||||
assert None == clean_dir('usr/local')
|
||||
assert not 'tmp/pisi-root' == clean_dir('usr/tmp')
|
||||
|
||||
def testDirSize(self):
|
||||
self.assertNotEqual(dir_size('usr/lib/pardus'),2940)
|
||||
self.assertNotEqual(dir_size('usr/lib'),65)
|
||||
|
||||
def testCopyFile(self):
|
||||
copy_file('/etc/pisi/pisi.conf','/usr/bin/aatest')
|
||||
copy_file('/etc/pisi/sandbox.conf', '/usr/bin/aclocal')
|
||||
copy_file_stat('/etc/pisi/pisi.conf','/usr/bin/aatest')
|
||||
@@ -0,0 +1,75 @@
|
||||
# Copyright (C) 2005 - 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
|
||||
|
||||
from pisi.version import Version
|
||||
|
||||
class VersionTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def testSingle(self):
|
||||
v1 = Version("103")
|
||||
v2 = Version("90")
|
||||
self.assert_(v1 > v2)
|
||||
|
||||
def testOpsNumerical(self):
|
||||
v1 = Version("0.3.1")
|
||||
v2 = Version("0.3.5")
|
||||
v3 = Version("1.5.2-4")
|
||||
v4 = Version("0.3.1-1")
|
||||
v5 = Version("2.07")
|
||||
self.assert_(v1 < v2)
|
||||
self.assert_(v3 > v2)
|
||||
self.assert_(v1 <= v3)
|
||||
self.assert_(v4 >= v4)
|
||||
self.assert_(v5 > v3)
|
||||
|
||||
def testOpsKeywords(self):
|
||||
# with keywords
|
||||
v1 = Version("2.23_pre10")
|
||||
v2 = Version("2.23")
|
||||
v3 = Version("2.21")
|
||||
v4 = Version("2.23_p1")
|
||||
v5 = Version("2.23_beta1")
|
||||
v6 = Version("2.23_m1")
|
||||
v7 = Version("2.23_rc1")
|
||||
v8 = Version("2.23_rc2")
|
||||
self.assert_(v1 < v2)
|
||||
self.assert_(v1 > v3)
|
||||
self.assert_(v1 < v4)
|
||||
self.assert_(v1 > v5)
|
||||
self.assert_(v2 < v4)
|
||||
self.assert_(v2 > v5)
|
||||
self.assert_(v6 < v4)
|
||||
self.assert_(v6 > v5)
|
||||
self.assert_(v7 > v5)
|
||||
self.assert_(v8 > v7)
|
||||
|
||||
v1 = Version("1.0_alpha1")
|
||||
v2 = Version("1.0_alpha2")
|
||||
self.assert_(v2 > v1)
|
||||
|
||||
def testOpsCharacters(self):
|
||||
# with character
|
||||
v1 = Version("2.10a")
|
||||
v2 = Version("2.10")
|
||||
v3 = Version("2.10d")
|
||||
self.assert_(v1 > v2)
|
||||
self.assert_(v1 < v3)
|
||||
self.assert_(v2 < v3)
|
||||
|
||||
def testGeBug(self):
|
||||
# bug 603
|
||||
v1 = Version('1.8.0')
|
||||
v2 = Version('1.9.1')
|
||||
self.assert_( not v1 > v2 )
|
||||
self.assert_( not v1 >= v2 )
|
||||
Reference in New Issue
Block a user