4

Currently, I´m working on a tool which shows the current price of one Bitcoin. Every minute, the price is updating with making a request with SocketIO which emits then the current price.

Now my issue is that I want to test the connection of the socket server and if it is receiving any request and if it is returning something but I actually don´t know how to do this.

I want to know this to create a better test "application" and to create "real" tests of this application with Travis CI.

Could someone help me there, please?

~ Julian Yaman

P.S.: Maybe you should checkout my repository to know what I´m talking about. (just in case)

julianYaman
  • 310
  • 4
  • 13
  • 3
    Have you seen the Flask-SocketIO test client? This is based on the same idea as the Flask test client, but for SocketIO events. Here is an example usage: https://github.com/miguelgrinberg/Flask-SocketIO/blob/master/test_socketio.py. – Miguel Grinberg Dec 18 '17 at 02:56
  • @Miguel and how could I now use this for my project? I saw many functions which I actually don´t really need. – julianYaman Dec 19 '17 at 22:28
  • I don't understand what you are asking, sorry. The file I pointed you at has unit tests for Flask-SocketIO. I thought that is what you wanted? Use that file as a model and write your own tests. – Miguel Grinberg Dec 20 '17 at 07:40
  • @Miguel, I had taken a look at that what you sent to me and tried to write my test application and adjusted the code to my project and now it works. Thank you for sending me this test file from FlaskSocketIO. – julianYaman Dec 20 '17 at 19:28

1 Answers1

3

Thanks to Miguel who sent me the test file from the repository from Flask-SocketIO! https://github.com/miguelgrinberg/Flask-SocketIO/blob/master/test_socketio.py

I adjusted my code with this template and now I have a good working test script for my program!

julianYaman
  • 310
  • 4
  • 13