Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_from_disk.py
# Copyright (C) 2017 The Software Heritage developers | # Copyright (C) 2017 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import os | import os | ||||
import pytest | |||||
import tarfile | import tarfile | ||||
import tempfile | import tempfile | ||||
import unittest | import unittest | ||||
import pytest | from typing import ClassVar, Optional | ||||
from swh.model import from_disk | from swh.model import from_disk | ||||
from swh.model.from_disk import Content, DentryPerms, Directory | from swh.model.from_disk import Content, DentryPerms, Directory | ||||
from swh.model.hashutil import DEFAULT_ALGORITHMS, hash_to_bytes, hash_to_hex | from swh.model.hashutil import DEFAULT_ALGORITHMS, hash_to_bytes, hash_to_hex | ||||
TEST_DATA = os.path.join(os.path.dirname(__file__), 'data') | TEST_DATA = os.path.join(os.path.dirname(__file__), 'data') | ||||
Show All 23 Lines | def setUp(self): | ||||
self.perms_map[i] = DentryPerms.content | self.perms_map[i] = DentryPerms.content | ||||
def test_exhaustive_mode_to_perms(self): | def test_exhaustive_mode_to_perms(self): | ||||
for fmode, perm in self.perms_map.items(): | for fmode, perm in self.perms_map.items(): | ||||
self.assertEqual(perm, from_disk.mode_to_perms(fmode)) | self.assertEqual(perm, from_disk.mode_to_perms(fmode)) | ||||
class DataMixin: | class DataMixin: | ||||
maxDiff = None | maxDiff = None # type: ClassVar[Optional[int]] | ||||
def setUp(self): | def setUp(self): | ||||
self.tmpdir = tempfile.TemporaryDirectory( | self.tmpdir = tempfile.TemporaryDirectory( | ||||
prefix='swh.model.from_disk' | prefix='swh.model.from_disk' | ||||
) | ) | ||||
self.tmpdir_name = os.fsencode(self.tmpdir.name) | self.tmpdir_name = os.fsencode(self.tmpdir.name) | ||||
self.contents = { | self.contents = { | ||||
▲ Show 20 Lines • Show All 728 Lines • Show Last 20 Lines |