Skip to content

Commit 7f19706

Browse files
author
sajidurrahman
committed
chore: better usage example in README.md and test renamed
1 parent d6ee4e8 commit 7f19706

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ pip install git+https://github.com/userlike/python-clamd.git
2727

2828
```python
2929
import clamd
30+
from io import BytesIO
3031

3132
# Connect via network
3233
cd = clamd.ClamdNetworkSocket(host='127.0.0.1', port=3310)
3334

3435
# Ping the daemon
35-
cd.ping()
36+
cd.ping() # Returns PONG, otherwise raise ConnectionError or ResponseError
3637

37-
# Scan a file
38+
# Scan content using instream (recommended - works with remote ClamAV)
39+
result = cd.instream(BytesIO(b'file content here'))
40+
# Returns: {'stream': ('OK', None)} for clean files
41+
# Returns: {'stream': ('FOUND', 'VirusName')} for infected files
42+
43+
# Scan a file by path (only works if ClamAV can access the path)
3844
cd.scan('/path/to/file')
3945

4046
# Get version info

src/tests/test_api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ def test_reload(self):
2626
assert self.cd.reload() == 'RELOADING'
2727

2828

29-
def test_instream(self):
29+
def test_instream_found(self):
30+
# Case: True positive
3031
expected = {'stream': ('FOUND', 'Eicar-Test-Signature')}
3132
assert self.cd.instream(BytesIO(clamd.EICAR)) == expected
3233

33-
def test_insteam_success(self):
34+
35+
def test_instream_ok(self):
36+
# Case True negative
3437
assert self.cd.instream(BytesIO(b"foo")) == {'stream': ('OK', None)}
3538

3639

0 commit comments

Comments
 (0)