Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_cli.py
# Copyright (C) 2018 The Software Heritage developers | # Copyright (C) 2018 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 tempfile | import tempfile | ||||
import unittest | import unittest | ||||
from click.testing import CliRunner | from click.testing import CliRunner | ||||
from nose.plugins.attrib import attr | from nose.plugins.attrib import attr | ||||
from swh.model import cli | from swh.model import cli | ||||
from swh.model.tests.test_from_disk import DataMixin | |||||
from swh.model.hashutil import hash_to_hex | from swh.model.hashutil import hash_to_hex | ||||
from swh.model.tests.test_from_disk import DataMixin | |||||
@attr('fs') | @attr('fs') | ||||
class TestIdentify(DataMixin, unittest.TestCase): | class TestIdentify(DataMixin, unittest.TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp() | super().setUp() | ||||
self.runner = CliRunner() | self.runner = CliRunner() | ||||
def assertPidOK(self, result, pid): | def assertPidOK(self, result, pid): # noqa: N802 | ||||
self.assertEqual(result.exit_code, 0) | self.assertEqual(result.exit_code, 0) | ||||
self.assertEqual(result.output.split()[0], pid) | self.assertEqual(result.output.split()[0], pid) | ||||
def test_content_id(self): | def test_content_id(self): | ||||
"""identify file content""" | """identify file content""" | ||||
self.make_contents(self.tmpdir_name) | self.make_contents(self.tmpdir_name) | ||||
for filename, content in self.contents.items(): | for filename, content in self.contents.items(): | ||||
path = os.path.join(self.tmpdir_name, filename) | path = os.path.join(self.tmpdir_name, filename) | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |