def test_filesystem_with_enough_space(self):

        framework = object()
        registry.initialize(framework, config.Config)
        f = FileSystemSpaceCheck(registry)

        self.results = capture_results(f)

        expected_results = 10 if in_container() else 12

        for result in self.results.results:
            assert result.result == constants.SUCCESS
            assert result.source == 'ipahealthcheck.system.filesystemspace'
            assert result.check == 'FileSystemSpaceCheck'
            assert ('free space percentage within' in result.kw.get('msg')
                    or 'free space within limits' in result.kw.get('msg'))
        assert len(self.results) == expected_results
    def test_filesystem_risking_fragmentation(self):

        framework = object()
        registry.initialize(framework)
        f = FileSystemSpaceCheck(registry)

        f.config = config.Config()
        self.results = capture_results(f)

        count = 0
        for result in self.results.results:
            if result.result == constants.ERROR:
                count += 1
                assert result.source == 'ipahealthcheck.system.filesystemspace'
                assert result.check == 'FileSystemSpaceCheck'
                assert 'free space percentage under' in result.kw.get('msg')
            else:
                assert 'free space within limits' in result.kw.get('msg')
        assert len(self.results) == 12
        assert count == 6
    def test_filesystem_near_enospc(self):

        framework = object()
        registry.initialize(framework, config.Config)
        f = FileSystemSpaceCheck(registry)

        self.results = capture_results(f)

        expected_results = 10 if in_container() else 12

        count = 0
        for result in self.results.results:
            if result.result == constants.ERROR:
                count += 1
                assert result.source == 'ipahealthcheck.system.filesystemspace'
                assert result.check == 'FileSystemSpaceCheck'
                assert 'free space under threshold' in result.kw.get('msg')
            else:
                assert 'free space percentage within' in result.kw.get('msg')
        assert len(self.results) == expected_results
        assert count == expected_results / 2