# Unit testing python vtk protocol

**URL:** <https://discourse.vtk.org/t/unit-testing-python-vtk-protocol/14779>\
**Category:** Development\
**Tags:** python\
**Created:** [October 28, 2024, 9:15pm UTC](https://discourse.vtk.org/t/unit-testing-python-vtk-protocol/14779 "2024-10-28T21:15:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Champagnol](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julien_champagnol/32/9415_2.png) [@Julien\_Champagnol](https://discourse.vtk.org/u/Julien_Champagnol)\
**Post date:** [October 28, 2024, 9:15pm UTC](https://discourse.vtk.org/t/unit-testing-python-vtk-protocol/14779/1 "2024-10-28T21:15:09Z")

</div>

Hi,

I’m trying to unit test a protocol that returns a binary file.  
I’m returning the file with a addAttachment and so far it’s working great with the front end.

But when I’m trying to unit test the python code all by itself, it doesn’t seem to behave the same way.  
This is what I’m returning : `return {"blob":self.addAttachment(file_content)}`  
The blob seems to be blocking the response, without the blob I get a `result` key in the response  
Here is the response with the blob :  
`response={'wslink': '1.0', 'method': 'wslink.binary.attachment', 'args': ['wslink_bin2']}`

From the wslink code I seem to understand that I need to call a specific rpc with the attachement id to get the file content, but I can’t figure out how.

Thanks in advance for your help,

---

<div class="post-metadata">

**Author:** ![Julien\_Champagnol](https://discourse.vtk.org/user_avatar/discourse.vtk.org/julien_champagnol/32/9415_2.png) [@Julien\_Champagnol](https://discourse.vtk.org/u/Julien_Champagnol)\
**Post date:** [October 29, 2024, 9:54am UTC](https://discourse.vtk.org/t/unit-testing-python-vtk-protocol/14779/2 "2024-10-29T09:54:34Z")

</div>

Found the solution, I had to call ws.recv() a second time to get the file

---

<div class="post-metadata">

**Author:** ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)\
**Post date:** [November 1, 2024, 7:48pm UTC](https://discourse.vtk.org/t/unit-testing-python-vtk-protocol/14779/3 "2024-11-01T19:48:24Z")

</div>

wslink comes with a JavaScript client that hide those protocols details.  
Also the latest major version of wslink rely on msgpack which change the structure of those binary messages. If your testing apply at a too low level they will fail if you update the py/js library of wslink.
