Exemplo n.º 1
0
    def test_getattr(self):
        mocked_lstat = MagicMock()
        mock_result = MagicMock()

        stats = (
            "st_atime",
            "st_ctime",
            "st_gid",
            "st_mode",
            "st_mtime",
            "st_nlink",
            "st_size",
            "st_uid",
        )
        for stat in stats:
            setattr(mock_result, stat, "mock_stat")

        mocked_lstat.return_value = mock_result

        with patch("gitfs.views.passthrough.os.lstat", mocked_lstat):
            view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
            result = view.getattr("/magic/path", 0)

            mocked_lstat.assert_called_once_with("/the/root/path/magic/path")

            assert result == dict(
                (key, getattr(mock_result, key)) for key in stats)
Exemplo n.º 2
0
    def test_getattr(self):
        mocked_lstat = MagicMock()
        mock_result = MagicMock()

        stats = ('st_atime', 'st_ctime', 'st_gid', 'st_mode', 'st_mtime',
                 'st_nlink', 'st_size', 'st_uid')
        for stat in stats:
            setattr(mock_result, stat, "mock_stat")

        mocked_lstat.return_value = mock_result

        with patch('gitfs.views.passthrough.os.lstat', mocked_lstat):
            view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
            result = view.getattr('/magic/path', 0)

            mocked_lstat.assert_called_once_with("/the/root/path/magic/path")

            assert result == dict((key, getattr(mock_result, key))
                                  for key in stats)