示例#1
0
 def test_path_in_path(self):
     good_path = TEST_DATA_DIR.join('hello', 'world')
     self.assertTrue(imscp.PathInPath(good_path, TEST_DATA_DIR) ==
                     FilePath('hello', 'world'))
     self.assertTrue(
         imscp.PathInPath(good_path, TEST_DATA_DIR.join('hello')) ==
         'world')
     bad_path = TEST_DATA_DIR.join('hello', 'worlds', 'bad')
     self.assertTrue(imscp.PathInPath(bad_path, good_path) is None,
                     bad_path)
     self.assertTrue(imscp.PathInPath(good_path, good_path) == '', "Match")
     self.assertTrue(imscp.PathInPath(TEST_DATA_DIR, good_path) is None,
                     "Path contains Path")
示例#2
0
 def test1_4_AssociatedContent_2(self):
     """A resource of the type associatedcontent must ...
     2. It must not contain any references to files above the directory
     containing the associated Learning Application Object's descriptor file."""
     for lao in self.cc.laoTable.keys():
         dPath, acr = self.cc.laoTable[lao]
         if acr is None:
             continue
         for f in acr.File:
             fPath = f.PackagePath(self.cc.cp)
             self.assertTrue(imscp.PathInPath(fPath, dPath))
示例#3
0
 def test1_4_WebContent_1(self):
     """A resource of the type "webcontent" must comply with the following
     restrictions...
     1. It may contain a file element for any file that exists in the package
     so long as the file is not in a Learning Application Object directory or
     a subdirectory of any Learning Application Object directory."""
     dPathList = []
     for lao in self.cc.laoTable.keys():
         dPath, acr = self.cc.laoTable[lao]
         if dPath is not None:
             dPathList.append(dPath)
     for wc in self.cc.cwcList:
         for f in wc.File:
             fPath = f.PackagePath(self.cc.cp)
             for dPath in dPathList:
                 self.assertFalse(imscp.PathInPath(fPath, dPath))
示例#4
0
 def GetACRListForDirectory(self, dPath):
     """Returns a list of associated content resources that have file's
     that reside in dPath.  (Used internally.)"""
     acrList = []
     fPaths = self.cc.cp.fileTable.keys()
     fPaths.sort()
     for fPath in fPaths:
         if imscp.PathInPath(fPath, dPath):
             fList = self.cc.cp.fileTable[fPath]
             foundResource = False
             for f in fList:
                 if f.parent.type != AssociatedContentType:
                     continue
                 if f.parent in acrList:
                     continue
                 acrList.append(f.parent)
     return acrList
示例#5
0
 def test1_4_AssociatedContent_1(self):
     """A resource of the type associatedcontent must ...
     1. ...contain a file element for each file that exists in the directory
     that contains the associated Learning Application Object's descriptor
     file or any of its subdirectories."""
     for lao in self.cc.laoTable.keys():
         laoResource = self.cc.cp.manifest.GetElementByID(lao)
         dPath, acr = self.cc.laoTable[lao]
         # acr must have a file element for all items in dPath
         fPaths = self.cc.cp.fileTable.keys()
         fPaths.sort()
         for fPath in fPaths:
             if imscp.PathInPath(fPath, dPath):
                 fList = self.cc.cp.fileTable[fPath]
                 foundResource = False
                 for f in fList:
                     if f.parent is acr:
                         foundResource = True
                         break
                     elif f.parent is laoResource:
                         foundResource = True
                         break
                 if not foundResource:
                     self.fail(fPath)