Exemplo n.º 1
0
    def test_stats(self):
        mocked_statvfs = MagicMock()
        mock_result = MagicMock()

        stats = (
            "f_bavail",
            "f_bfree",
            "f_blocks",
            "f_bsize",
            "f_favail",
            "f_ffree",
            "f_files",
            "f_flag",
            "f_frsize",
            "f_namemax",
        )
        for stat in stats:
            setattr(mock_result, stat, "mock_stat")

        mocked_statvfs.return_value = mock_result

        with patch("gitfs.views.passthrough.os.statvfs", mocked_statvfs):
            view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
            result = view.statfs("/magic/path")

            mocked_statvfs.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_stats(self):
        mocked_statvfs = MagicMock()
        mock_result = MagicMock()

        stats = ('f_bavail', 'f_bfree', 'f_blocks', 'f_bsize', 'f_favail',
                 'f_ffree', 'f_files', 'f_flag', 'f_frsize', 'f_namemax')
        for stat in stats:
            setattr(mock_result, stat, "mock_stat")

        mocked_statvfs.return_value = mock_result

        with patch('gitfs.views.passthrough.os.statvfs', mocked_statvfs):
            view = PassthroughView(repo=self.repo, repo_path=self.repo_path)
            result = view.statfs('/magic/path')

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

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