python-luxtronik icon indicating copy to clipboard operation
python-luxtronik copied to clipboard

Test the socket interaction by mocking the socket

Open gerw opened this issue 1 year ago • 2 comments

This provides almost 100% coverage of __init__.py. I am not sure about the missing lines. Sockets are weird, in particular checking whether a socket is closed / no longer usable.

Also the struct.error is not sensible in my opinion, but this should be discussed elsewhere.

Edit: And with the tests, I found a typo :)

gerw avatar Feb 26 '24 21:02 gerw

Coverage

Coverage Report
FileStmtsMissCoverMissing
luxtronik
   __init__.py1811492%42–43, 46–51, 210–212, 229–231, 246–248
   __main__.py21210%3–49
   datatypes.py275199%82
   discover.py403415%21–69
luxtronik/scripts
   dump_changes.py44440%5–85
   dump_luxtronik.py27270%5–52
TOTAL67514179% 

Tests Skipped Failures Errors Time
124 0 :zzz: 0 :x: 0 :fire: 3.969s :stopwatch:

github-actions[bot] avatar Feb 26 '24 21:02 github-actions[bot]

Nice 😎

I was tempted to implement tests for __init__.py but failed on mocking socket.socket, good work @gerw

Bouni avatar Feb 27 '24 13:02 Bouni