import unittest
import unittest.mock as mock

from ogn.client.client import TelnetClient


class TelnetClientTest(unittest.TestCase):
    @mock.patch('ogn.client.client.socket')
    def test_connect(self, socket_mock):
        def callback(raw_message):
            pass

        client = TelnetClient()
        client.run(callback=callback)

import unittest
import unittest.mock as mock

from ogn.client.client import TelnetClient


class TelnetClientTest(unittest.TestCase):
    @mock.patch('ogn.client.client.socket')
    def test_connect_disconnect(self, socket_mock):
        client = TelnetClient()
        client.connect()
        client.sock.connect.assert_called_once()

        client.disconnect()
        client.sock.shutdown.assert_called_once()
        client.sock.close.assert_called_once()

    @mock.patch('ogn.client.client.socket')
    def test_run(self, socket_mock):
        def callback(raw_message):
            raise ConnectionRefusedError

        client = TelnetClient()
        client.connect()

        client.run(callback=callback)

Update to receiver version 0.2.6
Update to receiver version 0.2.6

Update to receiver version 0.2.6

Better testing

  import unittest
  import unittest.mock as mock
  
  from ogn.client.client import TelnetClient
  
  
  class TelnetClientTest(unittest.TestCase):
      @mock.patch('ogn.client.client.socket')
+     def test_connect_disconnect(self, socket_mock):
+         client = TelnetClient()
+         client.connect()
+         client.sock.connect.assert_called_once()
+ 
+         client.disconnect()
+         client.sock.shutdown.assert_called_once()
+         client.sock.close.assert_called_once()
+ 
+     @mock.patch('ogn.client.client.socket')
-     def test_connect(self, socket_mock):
+     def test_run(self, socket_mock):
          def callback(raw_message):
-             pass
+             raise ConnectionRefusedError
  
          client = TelnetClient()
+         client.connect()
+ 
          client.run(callback=callback)
  
Update to receiver version 0.2.6
## Code Before:
import unittest
import unittest.mock as mock

from ogn.client.client import TelnetClient


class TelnetClientTest(unittest.TestCase):
    @mock.patch('ogn.client.client.socket')
    def test_connect(self, socket_mock):
        def callback(raw_message):
            pass

        client = TelnetClient()
        client.run(callback=callback)

## Instruction:
Update to receiver version 0.2.6
## Code After:
import unittest
import unittest.mock as mock

from ogn.client.client import TelnetClient


class TelnetClientTest(unittest.TestCase):
    @mock.patch('ogn.client.client.socket')
    def test_connect_disconnect(self, socket_mock):
        client = TelnetClient()
        client.connect()
        client.sock.connect.assert_called_once()

        client.disconnect()
        client.sock.shutdown.assert_called_once()
        client.sock.close.assert_called_once()

    @mock.patch('ogn.client.client.socket')
    def test_run(self, socket_mock):
        def callback(raw_message):
            raise ConnectionRefusedError

        client = TelnetClient()
        client.connect()

        client.run(callback=callback)
