Exemplo n.º 1
0
def test_edit_contact(app, db):
    app.open_page()
    if db.get_number_list() == 0:
        app.number.create_number(Number(firstname="testtest"))
    old_number = db.get_number_list()
    index = randrange(len(old_number))
    number = Number(lastname="1234567", firstname="sgfdxzdhxf")
    number.id = old_number[index].id
    app.number.edit_number_by_index(index, number)
    new_number = db.get_number_list()
    assert len(old_number) == len(new_number)
    old_number[index] = number
    assert sorted(old_number,
                  key=Number.id_or_max) == sorted(new_number,
                                                  key=Number.id_or_max)
Exemplo n.º 2
0
 def get_contact_info_from_edit_page(self, index):
     driver = self.app.driver
     self.open_number_to_edit_by_index(index)
     firstname = driver.find_element(By.NAME,
                                     "firstname").get_attribute("value")
     lastname = driver.find_element(By.NAME,
                                    "lastname").get_attribute("value")
     id = driver.find_element(By.NAME, "id").get_attribute("value")
     homephone = driver.find_element(By.NAME, "home").get_attribute("value")
     mobilephone = driver.find_element(By.NAME,
                                       "mobile").get_attribute("value")
     workphone = driver.find_element(By.NAME, "work").get_attribute("value")
     secondaryphone = driver.find_element(By.NAME,
                                          "phone2").get_attribute("value")
     address = driver.find_element(By.NAME,
                                   "address").get_attribute("value")
     email = driver.find_element(By.NAME, "email").get_attribute("value")
     email2 = driver.find_element(By.NAME, "email2").get_attribute("value")
     return Number(firstname=firstname,
                   lastname=lastname,
                   id=id,
                   homephone=homephone,
                   mobilephone=mobilephone,
                   workphone=workphone,
                   secondaryphone=secondaryphone,
                   address=address,
                   email=email,
                   email2=email2)
Exemplo n.º 3
0
    def __init__(self, wf):
        self.wf = wf
        if self.wf.update_available:
            wf.add_item('New version available',
                        'Action this item to install the update',
                        autocomplete='workflow:update',
                        icon=ICON_INFO)

        self.models = [
            DateTime(),
            MD5(),
            Base64(),
            Html(),
            Javascript(),
            SHA(),
            Number(),
            ASCII(),
            TheUUID(),
            String(),
            IPAddr(),
        ]
        self.modelDict = dict()
        self.max_age = 60 * 60 * 24 * 365
        for m in self.models:
            self.modelDict[m.name] = m
def test_add_number_in_group(app, orm):
    app.open_page()
    if orm.get_number_list() == 0:
        app.number.create_number(Number(firstname="testtest"))
    if len(orm.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    group = orm.get_group_list()
    group_id = random.choice(group).id
    app.number.add_number_in_group(group_id)
Exemplo n.º 5
0
 def get_number_from_view_page(self, index):
     driver = self.app.driver
     self.open_number_view_by_index(index)
     text = driver.find_element(By.ID, "content").text
     homephone = re.search("H: (.*)", text).group(1)
     mobilephone = re.search("M: (.*)", text).group(1)
     workphone = re.search("W: (.*)", text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return Number(homephone=homephone,
                   mobilephone=mobilephone,
                   workphone=workphone,
                   secondaryphone=secondaryphone)
Exemplo n.º 6
0
def test_delete_number_from_group(app, db, orm):
    app.open_page()
    if db.get_number_list() == 0:
        app.number.create_number(Number(firstname="testtest"))
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    group = db.get_group_list()
    group_id = random.choice(group).id
    number_id = random.choice(orm.get_numbers_in_group(Group(id=group_id))).id
    app.number.delete_number_from_group(group_id)
    assert db.get_number_by_id(id=number_id) not in orm.get_numbers_in_group(
        Group(id=group_id))
Exemplo n.º 7
0
def test_delete_some_contact(app, db, check_ui):
    app.open_page()
    if len(db.get_number_list()) == 0:
        app.number.create_number(Number(firstname="testtest"))
    old_number = db.get_number_list()
    number = random.choice(old_number)
    app.number.delete_number_by_id(number.id)
    new_number = db.get_number_list()
    assert len(old_number) - 1 == len(new_number)
    old_number.remove(number)
    assert old_number == new_number
    if check_ui:
        assert sorted(new_number, key=Number.id_or_max) == sorted(app.number.get_number_list(), key=Number.id_or_max)
Exemplo n.º 8
0
 def get_number_by_id(self, num_id):
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname from addressbook where "
             "deprecated='0000-00-00 00:00:00' and id='%s' % number_id")
         for row in cursor:
             (id, firstname, lastname) = row
             num_id = (Number(id=str(id),
                              firstname=firstname,
                              lastname=lastname))
     finally:
         cursor.close()
     return num_id
Exemplo n.º 9
0
 def get_number_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname from addressbook where deprecated='0000-00-00 00:00:00'"
         )
         for row in cursor:
             (id, firstname, lastname) = row
             list.append(
                 Number(id=id, firstname=firstname, lastname=lastname))
     finally:
         cursor.close()
     return list
Exemplo n.º 10
0
 def get_number_list(self):
     if self.number_cache is None:
         driver = self.app.driver
         self.open_number_page()
         self.number_cache = []
         for element in driver.find_elements(By.XPATH,
                                             "//*[@name = 'entry']"):
             cells = element.find_elements(By.XPATH, "//tr/td")
             firstname = cells[2].text
             lastname = cells[1].text
             id = cells[0].find_element(By.TAG_NAME,
                                        "input").get_attribute("value")
             all_phones = cells[5].text
             all_emails = cells[4].text
             address = cells[3].text
             self.number_cache.append(
                 Number(firstname=firstname,
                        lastname=lastname,
                        id=id,
                        all_phones_from_home_page=all_phones,
                        address=address,
                        all_emails=all_emails))
     return list(self.number_cache)
Exemplo n.º 11
0
    opts, args = getopt.getopt(sys.argv[1:], "n:f:", ["number of contacts", "file"])
except getopt.GetoptError as err:
    getopt.usage()
    sys.exit(2)

n = 5
f = "data/numbers.json"

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 + string.punctuation + "" * 10
    return prefix + "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [Number(firstname="", lastname="", address="", company="")] + [
    Number(firstname=random_string("firstname", 10), lastname=random_string("lastname", 15),
           address=random_string("address", 20),
           company=random_string("company", 15))
    for i in range(n)
]

file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f)

with open(file, "w") as out:
    jsonpickle.set_encoder_options("json", indent=2)
    out.write(jsonpickle.encode(testdata))
Exemplo n.º 12
0
from model.number import Number
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 = [Number(firstname="", lastname="", address="", company="")] + [
    Number(firstname="firstname1", lastname="lastname1",
           address="sddress1", company="company1")
    for i in range(5)
]
Exemplo n.º 13
0
 def convert(number):
     return Number(id=str(number.id), firstname=number.firstname, lastname=number.lastname)