Skip to content

Commit ab9972b

Browse files
committed
add test case for fdscan method
1 parent ca952a1 commit ab9972b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/tests/test_api.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
from __future__ import unicode_literals
4-
import clamd
5-
from io import BytesIO
6-
from contextlib import contextmanager
7-
import tempfile
8-
import shutil
91
import os
2+
import shutil
103
import stat
4+
import tempfile
5+
from contextlib import contextmanager
6+
from io import BytesIO
117

8+
import clamd
129
import pytest
1310

1411
mine = (stat.S_IREAD | stat.S_IWRITE)
@@ -77,6 +74,15 @@ def test_instream(self):
7774
def test_insteam_success(self):
7875
assert self.cd.instream(BytesIO(b"foo")) == {'stream': ('OK', None)}
7976

77+
def test_fdscan(self):
78+
with tempfile.NamedTemporaryFile('wb', prefix="python-clamd") as f:
79+
f.write(clamd.EICAR)
80+
f.flush()
81+
os.fchmod(f.fileno(), (mine | other))
82+
expected = {f.name: ('FOUND', 'Eicar-Test-Signature')}
83+
84+
assert self.cd.fdscan(f.name) == expected
85+
8086

8187
class TestUnixSocketTimeout(TestUnixSocket):
8288
kwargs = {"timeout": 20}

0 commit comments

Comments
 (0)