Ejemplo n.º 1
0
def test_edit_first_user_all(app, db, check_ui):
    if len(db.get_user_list()) == 0:
        app.user.create(MyUser(first_name="user"))

    old_users = db.get_user_list()
    user_random = random.choice(old_users)

    user = MyUser("Dima", "Miha", "Yakov", "DimYa", "t", "N", "1", "9", "7",
                  "7", "d", "*****@*****.**", "*****@*****.**", "www.dima.ru",
                  "15", "April", "1983", "1", "January", "1970", "Berdsk", "1",
                  "142")
    user.id = user_random.id
    app.user.edit_user_by_id(user, user.id)

    new_users = db.get_user_list()
    assert len(old_users) == len(new_users)

    old_users.remove(user_random)
    old_users.append(user)
    assert sorted(old_users,
                  key=MyUser.id_or_max) == sorted(new_users,
                                                  key=MyUser.id_or_max)

    if check_ui:
        assert sorted(new_users, key=MyUser.id_or_max) == sorted(
            app.user.get_user_list_from_home_page(), key=MyUser.id_or_max)
Ejemplo n.º 2
0
    def get_user_info_by_index_from_edit_page(self, index):
        wd = self.app.wd
        self.select_user_by_index_to_edit(index)

        first_name = wd.find_element_by_name("firstname").get_attribute(
            "value")
        last_name = wd.find_element_by_name("lastname").get_attribute("value")
        id = wd.find_element_by_name("id").get_attribute("value")

        home_phone = wd.find_element_by_name("home").get_attribute("value")
        mobile_phone = wd.find_element_by_name("mobile").get_attribute("value")
        work_phone = wd.find_element_by_name("work").get_attribute("value")
        phone2 = wd.find_element_by_name("phone2").get_attribute("value")

        email = wd.find_element_by_name("email").get_attribute("value")
        email2 = wd.find_element_by_name("email2").get_attribute("value")
        email3 = wd.find_element_by_name("email3").get_attribute("value")

        address = wd.find_element_by_name("address").text
        address2 = wd.find_element_by_name("address2").text

        return MyUser(first_name=first_name,
                      last_name=last_name,
                      home_phone=home_phone,
                      mobile_phone=mobile_phone,
                      work_phone=work_phone,
                      phone2=phone2,
                      id=id,
                      email=email,
                      email2=email2,
                      email3=email3,
                      address=address,
                      address2=address2)
Ejemplo n.º 3
0
 def convert(user):
     return MyUser(id=str(user.id),
                   first_name=user.firstname,
                   last_name=user.lastname,
                   address=user.address,
                   home_phone=user.home_phone,
                   mobile_phone=user.mobile_phone,
                   work_phone=user.work_phone,
                   phone2=user.phone2,
                   email=user.email,
                   email2=user.email2,
                   email3=user.email3)
Ejemplo n.º 4
0
    def get_user_info_by_index_from_view_page(self, index):
        wd = self.app.wd
        self.select_user_by_index_to_view(index)
        text = wd.find_element_by_id("content").text
        home_phone = re.search("H: (.*)", text)
        work_phone = re.search("W: (.*)", text)
        mobile_phone = re.search("M: (.*)", text)
        phone2_phone = re.search("P: (.*)", text)

        return MyUser(home_phone=home_phone,
                      work_phone=work_phone,
                      mobile_phone=mobile_phone,
                      phone2=phone2_phone)
Ejemplo n.º 5
0
def test_del_user(app, db, check_ui):
    if len(db.get_user_list()) == 0:
        app.user.create(MyUser(first_name="user"))

        old_users = db.get_user_list()

        user = random.choice(old_users)

        app.user.delete_user_by_id(user.id)

        new_users = db.get_user_list()
        assert len(old_users) - 1 == len(new_users)

        old_users.remove(user)
        assert old_users == new_users

    if check_ui:
        assert sorted(new_users, key=MyUser.id_or_max) == sorted(
            app.user.get_user_list_from_home_page(), key=MyUser.id_or_max)
Ejemplo n.º 6
0
    def get_user_list(self):
        list = []
        cursor = self.connection.cursor()

        try:
            cursor.execute(
                "select id, firstname, middlename, lastname, nickname, company from addressbook where deprecated='0000-00-00 00:00:00'"
            )
            for row in cursor:
                (id, firstname, middlename, lastname, nickname, company) = row
                list.append(
                    MyUser(id=str(id),
                           first_name=firstname,
                           last_name=lastname,
                           middle_name=middlename,
                           nick_name=nickname,
                           company=company))
        finally:
            cursor.close()
        return list
Ejemplo n.º 7
0
 def get_user_list_from_home_page(self):
     if self.user_cache is None:
         wd = self.app.wd
         self.open_user_home_page()
         self.user_cache = []
         if self.count() > 0:
             for entry in wd.find_element_by_id(
                     "maintable").find_elements_by_name("entry"):
                 td = entry.find_elements_by_tag_name("td")
                 user_id = td[0].find_element_by_name(
                     "selected[]").get_attribute("value")
                 first_name = td[2].text
                 last_name = td[1].text
                 all_phones = td[5].text
                 addreses = td[3].text
                 all_emails = td[4].text
                 self.user_cache.append(
                     MyUser(first_name=first_name,
                            last_name=last_name,
                            id=user_id,
                            all_phones_from_home_page=all_phones,
                            address=addreses,
                            all_emails_from_home_page=all_emails))
     return self.user_cache
Ejemplo n.º 8
0
for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a


def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + " "
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [
    MyUser(first_name="", last_name="", home_phone="", address="", email="")
] + [
    MyUser(first_name=random_string("first_name", 10),
           middle_name=random_string("middle_name", 5),
           last_name=random_string("last_name", 10),
           nick_name=random_string("nick_name", 5),
           title=random_string("title", 5),
           company=random_string("company", 10),
           home_phone=random_string("home_phone", 15),
           mobile_phone=(random_string("mobile_phone", 15)),
           work_phone=random_string("work_phone", 15),
           fax_phone=random_string("fax_phone", 15),
           email=random_string("email", 10),
           email2=random_string("email2", 10),
           email3=random_string("email3", 10),
           homepage=random_string("homepage", 10),
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-
from model.myuser import MyUser

testdata = [
    MyUser(first_name="first_name1",
           last_name="last_name1",
           home_phone="home_phone1",
           address="address1",
           email="email1"),
    MyUser(first_name="first_name2",
           last_name="last_name2",
           home_phone="home_phone2",
           address="address2",
           email="email2")
]