* distinguish String and Text types for autoxml

* start working on specfilenew again
* make test suite smarter. by definition of a test suite, they can be
run out of order.
* change the behavior of first running and then reporting all errors. 
 now we see where the error belongs to clearly. better in the cases 
 with several errors.
This commit is contained in:
Eray Özkural
2005-10-25 15:23:47 +00:00
parent d0a2d7a285
commit 8a4a47ac00
6 changed files with 107 additions and 49 deletions
+1 -3
View File
@@ -35,12 +35,10 @@ _ = __trans.ugettext
import pisi import pisi
from pisi.xmlext import * from pisi.xmlext import *
from pisi.xmlfile import XmlFile from pisi.xmlfile import XmlFile
import pisi.xmlfile as xmlfile
from pisi.dependency import DepInfo from pisi.dependency import DepInfo
from pisi.util import Checks from pisi.util import Checks
#class Packager:
# __metaclass__ = xmlfile.autoxml
class PackagerInfo: class PackagerInfo:
def __init__(self, node = None): def __init__(self, node = None):
if node: if node:
+3 -3
View File
@@ -33,12 +33,12 @@ __metaclass__ = xmlfile.autoxml
class Packager: class Packager:
t_Name = [types.StringType, xmlfile.mandatory] t_Name = [xmlfile.String, xmlfile.mandatory]
t_Email = [types.StringType, xmlfile.mandatory] t_Email = [xmlfile.String, xmlfile.mandatory]
def __str__(self): def __str__(self):
s = "%s <%s>" % (self.name, self.email) s = "%s <%s>" % (self.name, self.email)
return s return s
class AdditionalFileInfo: class AdditionalFileInfo:
s_Filename = xmlfile.mandatory s_Filename = xmlfile.mandatory
+5 -1
View File
@@ -51,11 +51,14 @@ import pisi.util as util
class Error(pisi.Error): class Error(pisi.Error):
pass pass
# requirement specs
mandatory, optional = range(2) # poor man's enum mandatory, optional = range(2) # poor man's enum
# basic types # basic types
Text = types.StringType String = types.StringType
Text = types.UnicodeType
Integer = types.IntType Integer = types.IntType
#class datatype(type): #class datatype(type):
@@ -602,6 +605,7 @@ class autoxml(type):
basic_cons_map = { basic_cons_map = {
types.StringType : str, types.StringType : str,
types.UnicodeType : unicode,
types.IntType : int types.IntType : int
} }
+17 -42
View File
@@ -18,58 +18,33 @@ import locale
sys.path.append('.') sys.path.append('.')
sys.path.append('..') sys.path.append('..')
runTestSuite = lambda(x): unittest.TextTestRunner(verbosity=2).run(x) def run_test_suite(testsuite):
unittest.TextTestRunner(verbosity=2).run(testsuite)
def run_all(): def run_all():
import utiltests print '** Running all tests'
import xmlfiletests #testsuite = unittest.TestSuite()
import specfiletests for root, dirs, files in os.walk('tests'):
import metadatatests testsources = filter(lambda x:x.endswith('tests.py'), files)
import constantstests for testsource in testsources:
import fetchertests module = __import__(testsource[:len(testsource)-3])
import archivetests #testsuite.add(module.suite)
import installdbtests print '\n* Running tests in', testsource
import sourcedbtests run_test_suite(module.suite)
import packagedbtests
import actionsapitests
import graphtests
import versiontests
import configfiletests
import packagetests
import dependency
alltests = unittest.TestSuite(( #run_test_suite(unittest.TestSuite(tests))
utiltests.suite,
xmlfiletests.suite,
specfiletests.suite,
metadatatests.suite,
constantstests.suite,
fetchertests.suite,
archivetests.suite,
installdbtests.suite,
sourcedbtests.suite,
packagedbtests.suite,
# FIXME: actionsapitests requires tester to run a specific command first.
# actionsapitests.suite,
graphtests.suite,
versiontests.suite,
configfiletests.suite,
packagetests.suite,
dependencytests.suite
))
runTestSuite(alltests)
if __name__ == "__main__": if __name__ == "__main__":
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
args = sys.argv args = sys.argv
if len(args) > 1: # run modules given from the command line if len(args) > 1: # run modules given from the command line
tests = sys.argv[1:] tests = sys.argv[1:]
for test in tests: for test in tests:
module = __import__(test + 'tests') test += 'tests'
print "\nRunning tests in '%s'...\n" % (test) module = __import__(test)
runTestSuite(module.suite) print "* Running tests in '%s'" % (test)
run_test_suite(module.suite)
else: # run all tests else: # run all tests
print "\nRunning all tests in order...\n"
run_all() run_all()
+80
View File
@@ -0,0 +1,80 @@
# Copyright (C) 2005, 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 os
from pisi import specfile
from pisi.config import config
import pisi.util as util
class SpecFileTestCase(unittest.TestCase):
def setUp(self):
self.spec = specfile.SpecFile()
self.spec.read("tests/popt/pspec.xml")
def testReadSpec(self):
self.assertEqual(self.spec.source.name, "popt")
self.assertEqual(self.spec.source.version, "1.7")
self.assertEqual(self.spec.source.release, "3")
self.assertEqual(self.spec.source.archiveSHA1,
"66f3c77b87a160951b180447f4a6dce68ad2f71b")
patches = self.spec.source.patches
self.assertEqual(len(patches), 1)
patch = patches[0] #get first and the only patch
self.assertEqual(patch.filename, "popt-1.7-uclibc.patch.gz")
self.assertEqual(patch.compressionType, "gz")
packages = self.spec.packages
self.assertEqual(len(packages), 1)
package = packages[0] # get the first and the only package
self.assertEqual(package.name, "popt-libs")
# search for a path in package.paths
pn = "/usr/lib"
matched = [p for p in package.paths if p.pathname == pn]
if not matched:
self.fail("Failed to match pathname: %s" %pn)
def testIsAPartOf(self):
# test existence in Source
if not "library:util:optparser" in self.spec.source.isa:
self.fail("Failed to match IsA in Source")
if not isinstance(self.spec.source.isa, list):
self.fail("source.isa is not a list, but it must be...")
if "rpm:archive" != self.spec.source.partof:
self.fail("Failed to match PartOf in Source")
# test existence in Package
pkg = self.spec.packages[0]
if not "library:util:optparser" in pkg.isa:
self.fail("Failed to match IsA in Package")
if not isinstance(pkg.isa, list):
self.fail("source.isa is not a list, but it must be...")
if "rpm:archive" != pkg.partof:
self.fail("Failed to match PartOf in Package")
def testVerify(self):
if self.spec.has_errors():
self.fail("Failed to verify specfile")
def testCopy(self):
util.check_dir(config.tmp_dir())
self.spec.read("tests/popt/pspec.xml")
self.spec.write(os.path.join(config.tmp_dir(), 'popt-copy.pspec.xml'))
suite = unittest.makeSuite(SpecFileTestCase)
+1
View File
@@ -32,3 +32,4 @@ class UtilTestCase(unittest.TestCase):
suite = unittest.makeSuite(UtilTestCase) suite = unittest.makeSuite(UtilTestCase)