# -*- coding: utf-8 -*-
from model.contact import Contact
# import pytest
# import random
# import string


# def random_string(prefix, maxlen):
#     symbols = string.ascii_letters + string.digits + string.punctuation + " "*10
#     return prefix + "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])
#
#
# testdata = [Contact(firstName="", lastName="", homePhone="")] + [
#     Contact(firstName=random_string("fn", 10), lastName=random_string("ln", 10), homePhone=random_string("+7", 11))
#     for i in range(5)
# ]


# @pytest.mark.parametrize("contact", testdata, ids=[repr(x) for x in testdata])
def test_add_contact(app, json_contacts):
    contact = json_contacts
    old_contacts = app.contacts.get_contact_list()
    # print(contact)
    app.contacts.create_contact(contact)
    app.contacts.return_to_contacts_page()
    assert len(old_contacts) + 1 == app.contacts.count()
    new_contacts = app.contacts.get_contact_list()
    old_contacts.append(contact)
    assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max)

