Ejemplo n.º 1
0
    def test_nested_files_to_copy(self):
        """Test that file copying works when tables have files."""
        # Create random test file
        testfile = "testfile.txt"
        with open(testfile, "w") as f:
            f.write("test")
        self.addCleanup(os.remove, testfile)

        # Output files
        testdirectory = "./testout"
        self.addCleanup(shutil.rmtree, testdirectory)
        self.addCleanup(os.remove, "submission.tar.gz")

        # Add resource to table, add table to Submission
        sub = Submission()
        tab = Table('test')
        tab.add_additional_resource("a_resource", testfile, True)
        sub.add_table(tab)

        # Write outputs
        sub.create_files(testdirectory)

        # Check that test file is actually in the tar ball
        with tarfile.open("submission.tar.gz", "r:gz") as tar:
            try:
                tar.getmember(testfile)
            except KeyError:
                self.fail(
                    "Submission.create_files failed to write all files to tar ball."
                )
Ejemplo n.º 2
0
    def test_copy_files(self):
        """Test the copy_files function."""
        test_table = Table("Some Table")
        some_pdf = "%s/minimal.pdf" % os.path.dirname(__file__)
        testdir = tmp_directory_name()
        self.addCleanup(shutil.rmtree, testdir)
        os.makedirs(testdir)

        test_table.add_additional_resource("a plot",some_pdf, copy_file=True)
        test_table.copy_files(testdir)
Ejemplo n.º 3
0
 def test_add_additional_resource(self): # pylint: disable=no-self-use
     """Test the add_additional_resource function."""
     test_table = Table("Some Table")
     test_table.add_additional_resource("some link","www.cern.ch")