Exemplo n.º 1
0
    def test_fedora_20(self):
        metadata = ExtraFiles()
        metadata.header.version = "1.0"
        metadata.compose.id = "Fedora-20-20131212.0"
        metadata.compose.type = "production"
        metadata.compose.date = "20131212"
        metadata.compose.respin = 0

        metadata.add(
            "Everything",
            "x86_64",
            "compose/Everything/x86_64/os/GPL",
            size=123,
            checksums={"md5": "abcde", "sha512": "a1b2c3"},
        )

        self._test_identity(metadata)
Exemplo n.º 2
0
 def test_absolute_path(self):
     metadata = ExtraFiles()
     self.assertRaises(
         ValueError,
         metadata.add,
         "Everything",
         "foobar",
         "/path",
         size=1,
         checksums={},
     )
Exemplo n.º 3
0
 def test_bad_arch(self):
     metadata = ExtraFiles()
     self.assertRaises(
         ValueError,
         metadata.add,
         "Everything",
         "foobar",
         "path/to/file",
         size=1,
         checksums={},
     )
Exemplo n.º 4
0
 def test_bad_checksums(self):
     metadata = ExtraFiles()
     self.assertRaises(
         TypeError,
         metadata.add,
         "Everything",
         "x86_64",
         "path/to/file",
         size=1,
         checksums="no",
     )
Exemplo n.º 5
0
    def test_partial_dump(self):
        metadata = ExtraFiles()
        metadata.header.version = "1.0"
        metadata.compose.id = "Fedora-20-20131212.0"
        metadata.compose.type = "production"
        metadata.compose.date = "20131212"
        metadata.compose.respin = 0

        metadata.add(
            "Everything",
            "x86_64",
            "compose/Everything/x86_64/os/GPL",
            size=123,
            checksums={"md5": "abcde", "sha512": "a1b2c3"},
        )

        out = StringIO()
        metadata.dump_for_tree(out, "Everything", "x86_64", "compose/Everything/x86_64/os")
        self.assertEqual(
            json.loads(out.getvalue()),
            {
                "header": {"version": "1.0"},
                "data": [
                    {
                        "file": "GPL",
                        "size": 123,
                        "checksums": {"md5": "abcde", "sha512": "a1b2c3"},
                    },
                ],
            },
        )
Exemplo n.º 6
0
    def _test_identity(self, modules):
        first = os.path.join(self.tmp_dir, "first")
        second = os.path.join(self.tmp_dir, "second")

        # write original file
        modules.dump(first)

        # read file and write it back
        modules = ExtraFiles()
        modules.load(first)
        modules.dump(second)

        # check if first and second files are identical
        self.assertSameFiles(first, second)
Exemplo n.º 7
0
    def test_partial_dump_in_deleted_directory(self):
        os.chdir(self.tmp_dir)
        shutil.rmtree(self.tmp_dir)

        metadata = ExtraFiles()
        metadata.header.version = "1.0"
        metadata.compose.id = "Fedora-20-20131212.0"
        metadata.compose.type = "production"
        metadata.compose.date = "20131212"
        metadata.compose.respin = 0

        metadata.add(
            "Everything",
            "x86_64",
            "compose/Everything/x86_64/os/GPL",
            size=123,
            checksums={"md5": "abcde", "sha512": "a1b2c3"},
        )

        out = StringIO()
        metadata.dump_for_tree(out, "Everything", "x86_64", "compose/Everything/x86_64/os")
Exemplo n.º 8
0
 def test_bad_variant(self):
     metadata = ExtraFiles()
     self.assertRaises(
         ValueError, metadata.add, "", "x86_64", "path/to/file", size=1, checksums={}
     )