def test_with_connections(self, datadir, monkeypatch) -> None:
        def return_data(*args, **kwargs):
            return (datadir / "smbstatus_with_connections").read_bytes()

        monkeypatch.setattr(subprocess, "check_output", return_data)

        res = Smb("foo").check()
        assert res is not None
        assert len(res.splitlines()) == 3
    def test_with_connections(self, monkeypatch):
        def return_data(*args, **kwargs):
            with open(os.path.join(os.path.dirname(__file__), 'test_data',
                                   'smbstatus_with_connections'), 'rb') as f:
                return f.read()
        monkeypatch.setattr(subprocess, 'check_output', return_data)

        assert Smb('foo').check() is not None
        assert len(Smb('foo').check().splitlines()) == 3
    def test_no_connections(self, datadir, monkeypatch) -> None:
        def return_data(*args, **kwargs):
            return (datadir / "smbstatus_no_connections").read_bytes()

        monkeypatch.setattr(subprocess, "check_output", return_data)

        assert Smb("foo").check() is None
    def test_call_error(self, mocker) -> None:
        mocker.patch(
            "subprocess.check_output",
            side_effect=subprocess.CalledProcessError(2, "cmd"),
        )

        with pytest.raises(SevereCheckError):
            Smb("foo").check()
 def test_create(self) -> None:
     assert isinstance(Smb.create("name", None), Smb)
 def create_instance(self, name):
     return Smb(name)
 def test_create(self):
     assert isinstance(Smb.create('name', None), Smb)
    def test_call_error(self, mocker):
        mocker.patch('subprocess.check_output',
                     side_effect=subprocess.CalledProcessError(2, 'cmd'))

        with pytest.raises(SevereCheckError):
            Smb('foo').check()