Beispiel #1
0
    def testCompile(self):
        """
        Compiles the schemas to a temporary directory and then checks
        that the pb2 files in the temporary direcory are the same as the
        pb2 files that are checked in.

        This test prevents inadvertent mismatches between proto files and
        pb2 files from being checked in.
        """
        # compile the schemas to a temporary directory
        scriptPath = 'scripts/process_schemas.py'
        schemaVersion = '.'.join(version.version.split('.')[0:3])
        schemasDir = 'src/main/proto/'
        schemaDest = tempfile.mkdtemp()
        cmd = "python {} {} -s {} -d {}".format(scriptPath, schemaVersion,
                                                schemasDir, schemaDest)
        utils.runCommand(cmd, silent=True)

        # get the file paths of the checked in pb2 files
        # (we do it in two calls to avoid the build/ tree, etc.
        # in the python directory which may contain pb2 files)
        pb2Patterns = ["*_pb2.py"]
        checkedInDirGa4gh = 'python/ga4gh/schemas/ga4gh/'
        checkedInDirGoogle = 'python/ga4gh/schemas/google/'
        checkedInFilePathsGa4gh = utils.getFilePathsWithExtensionsInDirectory(
            checkedInDirGa4gh, pb2Patterns)
        checkedInFilePathsGoogle = utils.getFilePathsWithExtensionsInDirectory(
            checkedInDirGoogle, pb2Patterns)
        checkedInFilePaths = sorted(checkedInFilePathsGa4gh +
                                    checkedInFilePathsGoogle)

        # check to see that the contents of the directories are the same
        tempFilePaths = utils.getFilePathsWithExtensionsInDirectory(
            schemaDest, pb2Patterns)
        self.assertEqual(len(checkedInFilePaths), len(tempFilePaths))
        for checkedInFilePath, tempFilePath in utils.zipLists(
                checkedInFilePaths, tempFilePaths):
            checkedInFileShortPath = self._getDirAndFilenameOfPath(
                checkedInFilePath)
            tempFileShortPath = self._getDirAndFilenameOfPath(tempFilePath)
            self.assertEqual(checkedInFileShortPath, tempFileShortPath)
            with open(checkedInFilePath) as checkedInFile, \
                    open(tempFilePath) as tempFile:
                for checkedInLine, tempLine in zip(checkedInFile, tempFile):
                    self.assertEqual(checkedInLine, tempLine)
Beispiel #2
0
    def testCompile(self):
        """
        Compiles the schemas to a temporary directory and then checks
        that the pb2 files in the temporary direcory are the same as the
        pb2 files that are checked in.

        This test prevents inadvertent mismatches between proto files and
        pb2 files from being checked in.
        """
        # compile the schemas to a temporary directory
        scriptPath = 'scripts/process_schemas.py'
        schemaVersion = '.'.join(version.version.split('.')[0:3])
        schemasDir = 'src/main/proto/'
        schemaDest = tempfile.mkdtemp()
        cmd = "python {} {} -s {} -d {}".format(
            scriptPath, schemaVersion, schemasDir, schemaDest)
        utils.runCommand(cmd, silent=True)

        # get the file paths of the checked in pb2 files
        # (we do it in two calls to avoid the build/ tree, etc.
        # in the python directory which may contain pb2 files)
        pb2Patterns = ["*_pb2.py"]
        checkedInDirGa4gh = 'python/ga4gh/schemas/ga4gh/'
        checkedInDirGoogle = 'python/ga4gh/schemas/google/'
        checkedInFilePathsGa4gh = utils.getFilePathsWithExtensionsInDirectory(
                checkedInDirGa4gh, pb2Patterns)
        checkedInFilePathsGoogle = utils.getFilePathsWithExtensionsInDirectory(
                checkedInDirGoogle, pb2Patterns)
        checkedInFilePaths = sorted(
            checkedInFilePathsGa4gh + checkedInFilePathsGoogle)

        # check to see that the contents of the directories are the same
        tempFilePaths = utils.getFilePathsWithExtensionsInDirectory(
            schemaDest, pb2Patterns)
        self.assertEqual(len(checkedInFilePaths), len(tempFilePaths))
        for checkedInFilePath, tempFilePath in utils.zipLists(
                checkedInFilePaths, tempFilePaths):
            checkedInFileShortPath = self._getDirAndFilenameOfPath(
                checkedInFilePath)
            tempFileShortPath = self._getDirAndFilenameOfPath(tempFilePath)
            self.assertEqual(checkedInFileShortPath, tempFileShortPath)
            with open(checkedInFilePath) as checkedInFile, \
                    open(tempFilePath) as tempFile:
                for checkedInLine, tempLine in zip(checkedInFile, tempFile):
                    self.assertEqual(checkedInLine, tempLine)
Beispiel #3
0
 def testRunCommandSplits(self):
     utils.runCommandSplits(self.validCommand.split())
     with self.assertRaises(subprocess.CalledProcessError):
         utils.runCommandSplits(self.invalidCommand.split(), silent=True)
     with self.assertRaises(Exception):
         utils.runCommand([self.nonexistentExecutable], silent=True)
Beispiel #4
0
def run(*args):
    cmd = "python repo_dev.py {}".format(" ".join(args))
    print("running:", cmd)
    utils.runCommand(cmd)
Beispiel #5
0
 def runTests(self):
     testCommands = self.parseTestCommands()
     for command in testCommands:
         self.log('Running: "{}"'.format(command))
         utils.runCommand(command)
     self.log('SUCCESS')
Beispiel #6
0
def run(*args):
    cmd = "python repo_dev.py {}".format(" ".join(args))
    print("running:", cmd)
    utils.runCommand(cmd)