Пример #1
0
def domain_users():

    user_1 = User(token=uuid.uuid4().hex,
                  email='*****@*****.**',
                  name='Jamie Fox',
                  user_type='customer')
    user_2 = User(token=uuid.uuid4().hex,
                  email='*****@*****.**',
                  name='Jamie Fox',
                  user_type='customer')
    user_3 = User(token=uuid.uuid4().hex,
                  email='*****@*****.**',
                  name='Jamie Fox',
                  user_type='staff')
    return [user_1, user_2, user_3]
def test_serialize_ticket_model():
    user = User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow')
    subject = 'TEST TEST TEST'
    dept = 'sales'
    priority = 'low'
    msg = 'lorem ipsum'
    code = uuid.uuid4().hex[:5]

    ticket = Ticket(user=user,
                    subject=subject,
                    department=dept,
                    priority=priority,
                    message=msg,
                    code=code,
                    created_at='5684747476')

    expected_json = """
        {{
            "user": {},
            "subject": "{}",
            "department": "{}",
            "priority": "{}",
            "message": "{}",
            "code": "{}",
            "closed": {},
            "created_at": "5684747476",
            "updated_at": null
        }}
    """.format(json.dumps(user, cls=UserJsonEncoder), subject, dept, priority,
               msg, code, "false")

    json_ticket = json.dumps(ticket, cls=TicketJsonEncoder)

    assert json.loads(json_ticket) == json.loads(expected_json)
def test_user_model_init():
    token = uuid.uuid4().hex
    email = '*****@*****.**'
    user_type = 'customer'
    name = 'John Doe'
    user = User(token=token, email=email, user_type=user_type, name=name)

    assert user.token == token
    assert user.email == email
    assert user.user_type == user_type
    assert user.name == name
def ticket_dicts():
    return [{
        'user':
        User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow'),
        'subject':
        'TEST TEST',
        'department':
        'technology',
        'priority':
        'high',
        'message':
        'lorem ipsum',
        'code':
        uuid.uuid4().hex[:4]
    }, {
        'user':
        User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow'),
        'subject':
        'TEST TEST',
        'department':
        'technology',
        'priority':
        'high',
        'message':
        'lorem ipsum',
        'code':
        uuid.uuid4().hex[:4]
    }, {
        'user':
        User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow'),
        'subject':
        'TEST TEST',
        'department':
        'technology',
        'priority':
        'high',
        'message':
        'lorem ipsum',
        'code':
        uuid.uuid4().hex[:4]
    }]
def domain_tickets():
    user_1 = User(token=uuid.uuid4().hex,
                  email='*****@*****.**',
                  name='Jamie Fox',
                  user_type='customer')
    user_2 = User(token=uuid.uuid4().hex,
                  email='*****@*****.**',
                  name='Jamie Fox',
                  user_type='customer')
    user_3 = User(token=uuid.uuid4().hex,
                  email='*****@*****.**',
                  name='Jamie Fox',
                  user_type='staff')
    domain_users = [user_1, user_2, user_3]

    return [
        Ticket(user=user,
               subject='TWEST',
               department='sales',
               priority='low',
               message='lorem ipsum',
               code=uuid.uuid4().hex[:5]) for user in domain_users
    ]
Пример #6
0
def test_serialize_user_model():
    token = uuid.uuid4().hex
    email = '*****@*****.**'
    user_type = 'customer'
    name = 'Jane Doe'

    user = User(token, email, user_type, name)

    expected_json = """
        {{
            "token": "{}",
            "email": "{}",
            "user_type": "{}",
            "name": "{}"
        }}
    """.format(token, email, user_type, name)

    json_user = json.dumps(user, cls=UserJsonEncoder)

    assert json.loads(json_user) == json.loads(expected_json)
Пример #7
0
def test_ticket_model_comparison():
    user = User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow')
    subject = 'TEST TEST TEST'
    dept = 'sales'
    priority = 'low'
    msg = 'lorem ipsum'
    code = uuid.uuid4().hex[:5]

    ticket_dict = {
        'user': user,
        'subject': subject,
        'department': dept,
        'priority': priority,
        'message': msg,
        'code': code
    }

    ticket1 = Ticket.from_dict(ticket_dict)
    ticket2 = Ticket.from_dict(ticket_dict)

    assert ticket1 == ticket2
Пример #8
0
def test_ticket_model_init():
    user = User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow')
    subject = 'TEST TEST TEST'
    dept = 'sales'
    priority = 'low'
    msg = 'lorem ipsum'
    code = uuid.uuid4().hex[:5]

    ticket = Ticket(user=user,
                    subject=subject,
                    department=dept,
                    priority=priority,
                    message=msg,
                    code=code)

    assert ticket.user == user
    assert ticket.subject == subject
    assert ticket.department == dept
    assert ticket.priority == priority
    assert ticket.message == msg
    assert ticket.code == code
Пример #9
0
def test_ticket_model_to_dict():
    user = User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow')
    subject = 'TEST TEST TEST'
    dept = 'sales'
    priority = 'low'
    msg = 'lorem ipsum'
    code = uuid.uuid4().hex[:5]

    ticket_dict = {
        'user': user,
        'subject': subject,
        'department': dept,
        'priority': priority,
        'message': msg,
        'code': code,
        'closed': False,
        'created_at': None,
        'updated_at': None
    }

    ticket = Ticket.from_dict(ticket_dict)

    assert ticket.to_dict() == ticket_dict
Пример #10
0
def test_ticket_model_from_dict():
    user = User(uuid.uuid4().hex, '*****@*****.**', 'customer', 'jerry dow')
    subject = 'TEST TEST TEST'
    dept = 'sales'
    priority = 'low'
    msg = 'lorem ipsum'
    code = uuid.uuid4().hex[:5]

    ticket = Ticket.from_dict({
        'user': user,
        'subject': subject,
        'department': dept,
        'priority': priority,
        'message': msg,
        'code': code
    })

    assert ticket.user == user
    assert ticket.subject == subject
    assert ticket.department == dept
    assert ticket.priority == priority
    assert ticket.message == msg
    assert ticket.code == code