def test_register_client_with_invalid_config_not_added(client_conf, monkeypatch): monkeypatch.setattr(sut, 'clients', []) mock_ws = Mock() mock_ws.receive.return_value = client_conf with pytest.raises(ValueError): sut._register_client(mock_ws) assert len(sut.clients) == 0
def test_register_client_with_valid_config_gets_added(monkeypatch): monkeypatch.setattr(sut, 'clients', []) mock_ws = Mock() mock_ws.receive.return_value = json.dumps({}) sut._register_client(mock_ws) assert len(sut.clients) == 1 assert mock_ws in sut.clients assert mock_ws.send.called assert mock_ws.send.call_args[0][0] == sut.WELCOME_MSG
def test_reg_client_valid_conf(monkeypatch): monkeypatch.setattr(sut, 'clients', []) mock_ws = Mock() mock_ws.receive.return_value = json.dumps({}) sut._register_client(mock_ws) assert len(sut.clients) == 1 assert mock_ws in sut.clients assert mock_ws.send.called assert mock_ws.send.call_args[0][0] == sut.WELCOME_MSG
def test_register_empty_client_not_added(monkeypatch): monkeypatch.setattr(sut, 'clients', []) with pytest.raises(Exception): sut._register_client(None) assert len(sut.clients) == 0
def test_reg_empty_client(monkeypatch): monkeypatch.setattr(sut, 'clients', []) with pytest.raises(Exception): sut._register_client(None) assert len(sut.clients) == 0