Ejemplo n.º 1
0
    def test_read_temp_file(self):
        with tempfile.NamedTemporaryFile("ab") as tf:
            tf.write(b"temp file test")
            tf.flush()
            temp_file = PulpTemporaryFile(file=tf.name)
            temp_file.save()

        assert b"temp file test" in temp_file.file.read()
Ejemplo n.º 2
0
    def test_storage_location(self):
        if settings.DEFAULT_FILE_STORAGE != "pulpcore.app.models.storage.FileSystem":
            self.skipTest("Skipping test for nonlocal storage.")

        with tempfile.NamedTemporaryFile("ab") as tf:
            temp_file = PulpTemporaryFile(file=tf.name)
            temp_file.save()

        assert temp_file.file.name.startswith("tmp/files/")
        assert temp_file.file.file.name.startswith("/var/lib/pulp/tmp/files")