示例#1
0
 def testCasePackagePaths(self):
     cp = ContentPackage(TEST_DATA_DIR.join('package_3'))
     goodPath = FilePath(cp.dPath, 'hello', 'world')
     self.assertTrue(cp.PackagePath(goodPath) == FilePath('hello', 'world'))
     badPath = TEST_DATA_DIR.join('package_3x', 'hello', 'world')
     self.assertTrue(cp.PackagePath(badPath) is None, badPath)
     badPath = TEST_DATA_DIR.join('package_x')
     self.assertTrue(cp.PackagePath(badPath) is None, badPath)
     badPath = TEST_DATA_DIR
     self.assertTrue(cp.PackagePath(badPath) is None, badPath)
示例#2
0
 def setUp(self):
     self.cwd = FilePath.getcwd()
     self.dList = []
     self.d = FilePath.mkdtemp('.d', 'pyslet-test_imscpv1p2-')
     self.d.chdir()
     FilePath('package').mkdir()
     FilePath('mpackage').mkdir()
     mpath = FilePath('mpackage', 'imsmanifest.xml')
     f = mpath.open('wb')
     f.write(EXAMPLE_2)
     f.close()
     self.dList.append(self.d)
示例#3
0
 def testCaseConstructor(self):
     cp = ContentPackage()
     self.assertTrue(cp.dPath.isdir(),
                     "Default constructor must create a temp directory")
     self.assertTrue(cp.GetPackageName() == 'imscp',
                     "Default package name is not empty string")
     # Ensure the temporary directory is cleaned up
     self.dList.append(cp.dPath)
     url = uri.URIFactory.URI(cp.manifest.GetBase())
     self.assertTrue(
         isinstance(cp.manifest, xmlns.XMLNSDocument)
         and isinstance(cp.manifest.root, Manifest),
         "Constructor must create manifest")
     self.assertTrue(
         url.GetVirtualFilePath().split()[1] == 'imsmanifest.xml',
         "Manifest file name")
     self.assertTrue(isinstance(cp.manifest.root, Manifest),
                     "Constructor must create manifest element")
     id = cp.manifest.root.id
     self.assertTrue(
         cp.manifest.GetElementByID(id) is cp.manifest.root,
         "Manifest identifief not declared")
     self.assertTrue(url.GetVirtualFilePath().isfile(),
                     "Constructor must create manifest file")
     cp = ContentPackage('newpackage')
     self.assertTrue(
         cp.dPath.isdir() and FilePath('newpackage').abspath() == cp.dPath,
         "Constructor creates specified directory")
     self.assertTrue(cp.GetPackageName() == 'newpackage',
                     "Package name not taken from directory")
     cp = ContentPackage('package')
     self.assertTrue(
         FilePath('package').abspath() == cp.dPath,
         "Constructor with existing directory, no manifest")
     cp = ContentPackage('mpackage')
     self.assertTrue(cp.manifest.root.id == "MANIFEST-QTI-1",
                     "Constructor with existing directory and manifest")
     self.assertTrue(cp.GetPackageName() == 'mpackage',
                     "Package name wrongly affected by manifest")
     cp = ContentPackage(FilePath('mpackage', 'imsmanifest.xml'))
     self.assertTrue(
         cp.dPath.isdir() and FilePath('mpackage').abspath() == cp.dPath,
         "Constructor identifies pkg dir from manifest file")
     self.assertTrue(cp.manifest.root.id == "MANIFEST-QTI-1",
                     "Constructor from manifest file")
示例#4
0
 def testCasePathInPath(self):
     goodPath = TEST_DATA_DIR.join('hello', 'world')
     self.assertTrue(
         PathInPath(goodPath, TEST_DATA_DIR) == FilePath('hello', 'world'))
     self.assertTrue(
         PathInPath(goodPath, TEST_DATA_DIR.join('hello')) == 'world')
     badPath = TEST_DATA_DIR.join('hello', 'worlds', 'bad')
     self.assertTrue(PathInPath(badPath, goodPath) is None, badPath)
     self.assertTrue(PathInPath(goodPath, goodPath) == '', "Match")
     self.assertTrue(
         PathInPath(TEST_DATA_DIR, goodPath) is None, "Path contains Path")
示例#5
0
def suite():
    return unittest.TestSuite((
        unittest.makeSuite(CPTests, 'test'),
        unittest.makeSuite(CPElementTests, 'test'),
        unittest.makeSuite(CPDocumentTests, 'test'),
        unittest.makeSuite(CPManifestTests, 'test'),
        unittest.makeSuite(CPResourcesTests, 'test'),
        unittest.makeSuite(CPResourceTests, 'test'),
        unittest.makeSuite(ContentPackageTests, 'test'),
    ))


from pyslet.vfs import OSFilePath as FilePath

TEST_DATA_DIR = FilePath(
    FilePath(__file__).abspath().split()[0], 'data_imscpv1p2')

from pyslet.imscpv1p2 import *


class CPTests(unittest.TestCase):
    def testCaseConstants(self):
        self.assertTrue(
            IMSCP_NAMESPACE == "http://www.imsglobal.org/xsd/imscp_v1p1",
            "Wrong CP namespace: %s" % IMSCP_NAMESPACE)
        self.assertTrue(
            IMSCPX_NAMESPACE ==
            "http://www.imsglobal.org/xsd/imscp_extensionv1p2",
            "Wrong extension namespace: %s" % IMSCPX_NAMESPACE)

示例#6
0
import uuid
import unittest

import pyslet.odata2.csdl as edm
import pyslet.odata2.core as core
import pyslet.odata2.metadata as edmx
import pyslet.http.params as params
from pyslet.vfs import OSFilePath as FilePath

from test_odata2_core import DataServiceRegressionTests

import pyslet.odata2.sqlds as sqlds


TEST_DATA_DIR = FilePath(
    FilePath(__file__).abspath().split()[0],
    'data_odatav2')


def suite():
    loader = unittest.TestLoader()
    loader.testMethodPrefix = 'test'
    return unittest.TestSuite((
        loader.loadTestsFromTestCase(ParamTests),
        loader.loadTestsFromTestCase(ThreadTests),
        loader.loadTestsFromTestCase(SQLDSTests),
        loader.loadTestsFromTestCase(AutoFieldTests),
        loader.loadTestsFromTestCase(RegressionTests),
    ))

示例#7
0
    return unittest.TestSuite((loader.loadTestsFromTestCase(CSDLTests)))


def load_tests(loader, tests, pattern):
    return suite()


from pyslet.odata2.csdl import *

import pyslet.xml20081126.structures as xml
import pyslet.odata2.edmx as edmx
from pyslet.vfs import OSFilePath as FilePath

import decimal

TEST_DATA_DIR = FilePath(
    FilePath(__file__).abspath().split()[0], 'data_mc_csdl')


class CSDLTests(unittest.TestCase):
    def testCaseConstants(self):
        self.assertTrue(
            EDM_NAMESPACE == "http://schemas.microsoft.com/ado/2009/11/edm",
            "Wrong CSDL namespace: %s" % EDM_NAMESPACE)

    def testCaseSimpleIdentifier(self):
        # basic tests here:
        for iTest in ("45", "M'", "M;", "M=", "M\\", "M.N", "M+", "M-", "M*",
                      "M/", "M<", "M>", "M=", "M~", "M!", "M@", "M#", "M%",
                      "M^", "M&", "M|", "M`", "M?", "M(", "M)", "M[", "M]",
                      "M,", "M;", "M*", "M."):
            try: