Example #1
0
    def test_format_metadata_none(self):
        uuid = _uuid.uuid4()
        with io.StringIO() as fh:
            ArchiveFormat._format_metadata(fh, uuid, IntSequence1, None)
            result = fh.getvalue()

        self.assertEqual(result,
                         "uuid: %s\ntype: IntSequence1\nformat: null\n" % uuid)
Example #2
0
    def test_format_metadata_none(self):
        uuid = _uuid.uuid4()
        with io.StringIO() as fh:
            ArchiveFormat._format_metadata(fh, uuid, IntSequence1, None)
            result = fh.getvalue()

        self.assertEqual(result,
                         "uuid: %s\ntype: IntSequence1\nformat: null\n" % uuid)
Example #3
0
    def test_load_root_dir_metadata_uuid_mismatch(self):
        fp = pathlib.Path(self.temp_dir.name) / 'root-dir-metadata-mismatch'
        fp.mkdir()

        r = _ZipArchive.setup(fp, 'foo', 'bar')
        fake = ArchiveRecord(r.root, r.version_fp,
                             _uuid.uuid4(),  # This will trick the format
                             r.version, r.framework_version)

        ArchiveFormat.write(fake, IntSequence1, IntSequenceDirectoryFormat,
                            lambda x: None, None)
        with self.assertRaisesRegex(
                ValueError, 'root directory must match UUID.*metadata'):
            ArchiveFormat(r)
Example #4
0
    def test_load_root_dir_metadata_uuid_mismatch(self):
        fp = pathlib.Path(self.temp_dir.name) / 'root-dir-metadata-mismatch'
        fp.mkdir()

        r = _ZipArchive.setup(fp, 'foo', 'bar')
        fake = ArchiveRecord(
            r.root,
            r.version_fp,
            _uuid.uuid4(),  # This will trick the format
            r.version,
            r.framework_version)

        ArchiveFormat.write(fake, IntSequence1, IntSequenceDirectoryFormat,
                            lambda x: None, None)
        with self.assertRaisesRegex(
                ValueError, 'root directory must match UUID.*metadata'):
            ArchiveFormat(r)