Exemplo n.º 1
0
    def test_write_message(self, mock_connection):
        ac = ActiveConnections()

        c = MockConnection()
        ac.connections = [c]

        ac.write_message({"key": "value"})

        mock_connection.assert_called_once_with(json.dumps({"key": "value"}))
Exemplo n.º 2
0
    def test_write_message(self, mock_connection):
        ac = ActiveConnections()

        c = MockConnection()
        ac.connections = [c]

        ac.write_message({'key': 'value'})

        mock_connection.assert_called_once_with(json.dumps({'key': 'value'}))
Exemplo n.º 3
0
    def test_double_remove(self):
        ac = ActiveConnections()

        c = MockConnection()

        ac.connections = [c]

        ac.remove(c)
        ac.remove(c)

        assert len(ac.connections) == 0
Exemplo n.º 4
0
    def test_remove(self):
        ac = ActiveConnections()
        c1 = MockConnection()
        c2 = MockConnection()

        ac.connections = [c1, c2]

        ac.remove(c1)

        assert c1 not in ac.connections
        assert c2 in ac.connections
Exemplo n.º 5
0
    def test_double_remove(self):
        ac = ActiveConnections()

        c = MockConnection()

        ac.connections = [c]

        ac.remove(c)
        ac.remove(c)

        assert len(ac.connections) == 0
Exemplo n.º 6
0
    def test_remove(self):
        ac = ActiveConnections()
        c1 = MockConnection()
        c2 = MockConnection()

        ac.connections = [c1, c2]

        ac.remove(c1)

        assert c1 not in ac.connections
        assert c2 in ac.connections