import chirc.replies as replies
import pytest
from chirc.types import ReplyTimeoutException

@pytest.mark.category("BASIC_CONNECTION")
class TestBasicConnection(object):

    def test_connect_simple(self, irc_session):
        client = irc_session.get_client(nodelay = True)
        
        client.send_raw(["NICK user1\r\n", 
                         "USER user1 * * :User One\r\n"],
                        wait=0.05)
        
        irc_session.get_reply(client, expect_code = replies.RPL_WELCOME, expect_nick="user1", expect_nparams = 1,
                              long_param_re= "Welcome to the Internet Relay Network user1!user1@.*")

    def test_connect_both_messages_at_once(self, irc_session):
        client = irc_session.get_client(nodelay = True)
        
        client.send_raw("NICK user1\r\nUSER user1 * * :User One\r\n")
        
        irc_session.get_reply(client, expect_code = replies.RPL_WELCOME, expect_nick="user1", expect_nparams = 1)

    def test_connect_partitioned_messages1(self, irc_session):
        client = irc_session.get_client(nodelay = True)
        
        client.send_raw(["NICK ", 
                         "user1\r\nUSER user1 * * :User One\r\n"],
                        wait=0.05)
        
        irc_session.get_reply(client, expect_code = replies.RPL_WELCOME, expect_nick="user1", expect_nparams = 1)

    def test_connect_partitioned_messages2(self, irc_session):