def test_modify_address_middlename(app):
    if app.address.count() == 0:
        app.address.create(Address(firstname='test'))
    old_address = app.address.get_address_list()
    app.address.modify_first_address(Address(lastname="9999"))
    new_address = app.address.get_address_list()
    assert len(old_address) == len(new_address)
Exemple #2
0
def test_add_address_in_group(app, db):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name='test'))
    if len(app.address.check_none_list(value="[none]")) == 0:
        app.group.create(Group(name='test'))
        app.address.create(Address(firstname='test'))
    with allure.step('Take info from db'):
        old_list = db.get_address_group_list()
    address = random.choice(app.address.check_none_list(value="[none]"))
    group = random.choice(app.group.get_group_list())
    with allure.step('Paste address to the group'):
        old_address_list_in_group = app.address.check_none_list(value=group.id)
    for row in old_address_list_in_group:
        assert row.id is not address.id
    app.address.selsect_address_by_id(address.id)
    app.group.select_group_into_address_list(group.id)
    position = Address(id=address.id, group_id=group.id)
    with allure.step('Asserts'):
        new_list = db.get_address_group_list()
    new_address_list_in_group = app.address.check_none_list(value=group.id)
    old_address_list_in_group.append(address)
    assert old_address_list_in_group == new_address_list_in_group
    assert len(old_list) + 1 == len(new_list)
    old_list.append(position)
    assert sorted(old_list, key=Group.id_or_max) == sorted(new_list,
                                                           key=Group.id_or_max)
def test_edit_address(app):
    if app.address.count() == 0:
        app.address.create(
            Address(first_name="Fname for editing",
                    midle_name="Mname for editing",
                    last_name="for editing",
                    nick_name="for editing"))
        app.address.submit()
    old_addresses = app.address.get_address_list()
    index = randrange(len(old_addresses))
    address = Address(first_name="Firstname (edited)",
                      midle_name="MidleName (edited)",
                      last_name="Lastname (edited)",
                      nick_name="NickName (edited)",
                      company="Ant (edited)",
                      addrs="123 (edited)",
                      home="123 (edited)",
                      mobile="123 (edited)",
                      work="1234 (edited)",
                      fax="12345 (edited)",
                      email="[email protected] (edited)")
    address.id = old_addresses[index].id
    app.address.edit(address, index)
    assert len(old_addresses) == app.address.count()
    new_addresses = app.address.get_address_list()
    old_addresses[index] = address
    assert sorted(old_addresses,
                  key=Address.id_or_max) == sorted(new_addresses,
                                                   key=Address.id_or_max)
def test_modify_kontakt_name(app):
    if app.kontakt.count() == 0:
        app.kontakt.create_address(Address(firstname="test"))
    old_kontakts = app.kontakt.get_kontakt_list()
    index = randrange(len(old_kontakts))
    kontakt = Address(firstname="New kontakt")
    kontakt.id = old_kontakts[index].id
    app.kontakt.modify_kontakt_by_index(index, kontakt)
    new_kontakts = app.kontakt.get_kontakt_list()
    assert len(old_kontakts) == len(new_kontakts)
    old_kontakts[index] = kontakt
    assert sorted(old_kontakts,
                  key=Address.id_or_max) == sorted(new_kontakts,
                                                   key=Address.id_or_max)
Exemple #5
0
def test_modify(app):
    if app.address.count() == 0:
        app.address.add(fixed_testdata[0])
    old_address_list = app.address.get_address_list()
    index = randrange(len(old_address_list))
    address = Address(first_name="VIKA", address="10Th Avenue")
    address.id = old_address_list[index].id
    address.title = old_address_list[index].title
    app.address.modify_by_index(index, address)
    new_address_list = app.address.get_address_list()
    assert len(old_address_list) == len(new_address_list)
    old_address_list[index] = address
    assert sorted(old_address_list,
                  key=Address.title) == sorted(new_address_list,
                                               key=Address.title)
Exemple #6
0
 def get_address_info_from_edit_page(self, index):
     wd = self.app.wd
     self.open_address_to_edit_by_index(index)
     firstname = wd.find_element_by_name("firstname").get_attribute("value")
     lastname = wd.find_element_by_name("lastname").get_attribute("value")
     id = wd.find_element_by_name("id").get_attribute("value")
     address = wd.find_element_by_name("address").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")
     homephone = wd.find_element_by_name("home").get_attribute("value")
     workphone = wd.find_element_by_name("work").get_attribute("value")
     mobile = wd.find_element_by_name("mobile").get_attribute("value")
     secondaryphone = wd.find_element_by_name("phone2").get_attribute(
         "value")
     return Address(firstname=firstname,
                    lastname=lastname,
                    id=id,
                    address=address,
                    email=email,
                    email2=email2,
                    email3=email3,
                    homephone=homephone,
                    workphone=workphone,
                    mobile=mobile,
                    secondaryphone=secondaryphone)
Exemple #7
0
 def get_address_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname, middlename, nickname, company, title, address, home, mobile, work, fax, email, email2, email3, homepage, phone2 from addressbook where deprecated='0000-00-00 00:00:00'"
         )
         for row in cursor:
             (id, first_name, last_name, middlename, nickname, company,
              title, address_home, home, mobile, work, fax, email, email2,
              email3, homepage, phone2) = row
             list.append(
                 Address(lastname=last_name,
                         firstname=first_name,
                         middlename=middlename,
                         nickname=nickname,
                         company=company,
                         title=title,
                         address_home=address_home,
                         id=str(id),
                         home=home,
                         mobile=mobile,
                         work=work,
                         fax=fax,
                         email=email,
                         email2=email2,
                         email3=email3,
                         homepage=homepage,
                         phone2=phone2))
     finally:
         cursor.close()
     return list
Exemple #8
0
 def get_contact_info_from_edit_page(self, index):
     wd = self.app.wd
     self.open_contact_to_edit_by_index(index)
     firstname = wd.find_element_by_name('firstname').get_attribute('value')
     lastname = wd.find_element_by_name('lastname').get_attribute('value')
     address_home = wd.find_element_by_name('address').get_attribute(
         'value')
     id = wd.find_element_by_name('id').get_attribute('value')
     #phones
     homephone = wd.find_element_by_name('home').get_attribute('value')
     workphone = wd.find_element_by_name('work').get_attribute('value')
     mobilephone = wd.find_element_by_name('mobile').get_attribute('value')
     secondaryphone = wd.find_element_by_name('phone2').get_attribute(
         'value')
     #for mail
     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')
     return Address(firstname=firstname,
                    lastname=lastname,
                    id=id,
                    address_home=address_home,
                    home=homephone,
                    mobile=mobilephone,
                    work=workphone,
                    phone2=secondaryphone,
                    email=email,
                    email2=email2,
                    email3=email3)
Exemple #9
0
 def get_address_info_from_edit_page(self, index):
     wd = self.app.wd
     self.select_address_by_index(index)
     wd.find_elements_by_css_selector("img[alt='Edit']")[index].click()
     firstname = wd.find_element_by_name("firstname").get_attribute("value")
     lastname = wd.find_element_by_name("lastname").get_attribute("value")
     id = wd.find_element_by_name("id").get_attribute("value")
     home = wd.find_element_by_name("home").get_attribute("value")
     work = wd.find_element_by_name("work").get_attribute("value")
     mobile = wd.find_element_by_name("mobile").get_attribute("value")
     secondaryphone = 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")
     return Address(first_name=firstname,
                    last_name=lastname,
                    id=id,
                    home=home,
                    work=work,
                    mobile=mobile,
                    secondaryphone=secondaryphone,
                    email=email,
                    email2=email2,
                    email3=email3)
 def get_address_info_from_edit_page(self, index):
     wd = self.app.wd
     self.open_address_to_edit_by_index(index)
     first_name = wd.find_element_by_name("firstname").get_attribute(
         "value")
     last_name = wd.find_element_by_name("lastname").get_attribute("value")
     # to jest ukryte pole w przegladarce
     id = wd.find_element_by_name("id").get_attribute("value")
     home_telephone = wd.find_element_by_name("home").get_attribute("value")
     work_telephone = wd.find_element_by_name("work").get_attribute("value")
     mobile_telephone = wd.find_element_by_name("mobile").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
     return Address(first_name=first_name,
                    last_name=last_name,
                    id=id,
                    home_telephone=home_telephone,
                    mobile_telephone=mobile_telephone,
                    work_telephone=work_telephone,
                    phone2=phone2,
                    email=email,
                    email2=email2,
                    email3=email3,
                    address=address)
Exemple #11
0
def test_modify_first_name(app, db, check_ui):
    if len(db.get_address_list()) == 0:
        app.address.new(
            Address(first_name="test", middle_name="test", last_name="test"))
    old_addresses = db.get_address_list()
    random_index = randrange(0, len(old_addresses))
    address = old_addresses[random_index]
    app.address.modify_address_by_id(
        address.id, Address(first_name="QWE", last_name="QWE"))
    new_addresses = db.get_address_list()
    assert len(old_addresses) == len(new_addresses)
    # old_addresses[random_index] = new_addresses[random_index]
    old_addresses[random_index] = db.get_address_by_id(address.id)
    assert old_addresses == new_addresses
    if check_ui:
        assert sorted(new_addresses, key=Address.id_or_max) == sorted(
            app.address.get_address_list(), key=Address.id_or_max)
Exemple #12
0
def test_add_new_kontakt(app):
    old_kontakts = app.kontakt.get_kontakt_list()
    kontakt = Address("Viktor", "Prihodko", "08998899854")
    app.kontakt.create_address(kontakt)
    assert len(old_kontakts) + 1 == app.kontakt.count()
    new_kontakts = app.kontakt.get_kontakt_list()
    old_kontakts.append(kontakt)
    assert sorted(old_kontakts, key=Address.id_or_max) == sorted(new_kontakts, key=Address.id_or_max)
Exemple #13
0
 def __init__(self, request, identifier, views, default_view_token, *args, **kwargs):
     _views = views or {}
     _uri = ''.join([config.URI_ADDRESS_INSTANCE_BASE, identifier])
     kwargs.setdefault('gnaf_template', 'class_address.html')
     kwargs.setdefault('dct_template', 'class_address.html')
     super(AddressRenderer, self).__init__(request, _uri, _views, default_view_token, *args, **kwargs)
     self.identifier = identifier
     self.instance = Address(self.identifier, focus=True)
Exemple #14
0
 def get_contact_from_view_page_by_id(self, id):
     wd = self.app.wd
     self.open_contact_view_by_id(id)
     text = wd.find_element_by_id('content').text
     home = re.search("H: (.*)", text).group(1)
     work = re.search("W: (.*)", text).group(1)
     mobile = re.search("M: (.*)", text).group(1)
     phone2 = re.search("P: (.*)", text).group(1)
     return Address(home=home, mobile=mobile, work=work, phone2=phone2)
def test_del_some_kontakt(app):
    if app.kontakt.count() == 0:
        app.kontakt.create_address(Address(firstname="test"))
    old_kontakts = app.kontakt.get_kontakt_list()
    index = randrange(len(old_kontakts))
    app.kontakt.del_kontakt_by_index(index)
    new_kontakts = app.kontakt.get_kontakt_list()
    assert len(old_kontakts) - 1 == len(new_kontakts)
    old_kontakts[index:index + 1] = []
    assert old_kontakts == new_kontakts
Exemple #16
0
 def get_address_group_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute("select id, group_id from address_in_groups")
         for row in cursor:
             (id, group_id) = row
             list.append(Address(id=str(id), group_id=str(group_id)))
     finally:
         cursor.close()
     return list
def test_edit_some_address_firstname(app, db, check_ui):
    if len(db.get_address_list()) == 0:
        app.address.add_new(
            Address(firstname="added",
                    lastname="added",
                    company="added",
                    address="added",
                    mobile="added",
                    email="added"))
    old_addresses = db.get_address_list()
    address = random.choice(old_addresses)
    new_address = Address(firstname="edited")
    app.address.edit_by_id(address.id, new_address)
    new_addresses = db.get_address_list()
    assert len(old_addresses) == len(new_addresses)
    address.firstname = new_address.firstname
    old = sorted(old_addresses, key=Address.id_or_max)
    new = sorted(new_addresses, key=Address.id_or_max)
    assert old == new
    if check_ui:
        test_address_list(app, db)
Exemple #18
0
    def create(cls, street, zip_code, province, city, complement, number):
        address = Address(street=street,
                          zip_code=zip_code,
                          province=province,
                          city=city,
                          complement=complement,
                          number=number)
        if cls.exists(address):
            raise UniqueObjectViolated

        cls.__db_session.add(address)
        cls.__db_session.commit()
Exemple #19
0
 def get_address_from_view_page(self, index):
     wd = self.app.wd
     self.view_by_index(index)
     text = wd.find_element_by_id("content").text
     homephone = re.search("H: (.*)", text).group(1)
     workphone = re.search("W: (.*)", text).group(1)
     mobile = re.search("M: (.*)", text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return Address(homephone=homephone,
                    workphone=workphone,
                    mobile=mobile,
                    secondaryphone=secondaryphone)
 def get_address_from_view_page(self, index):
     wd = self.app.wd
     self.open_address_view_by_index(index)
     text = wd.find_element_by_id("content").text
     home_telephone = re.search("H: (.*)", text).group(1)
     work_telephone = re.search("W: (.*)", text).group(1)
     mobile_telephone = re.search("M: (.*)", text).group(1)
     phone2 = re.search("P: (.*)", text).group(1)
     return Address(home_telephone=home_telephone,
                    mobile_telephone=mobile_telephone,
                    work_telephone=work_telephone,
                    phone2=phone2)
Exemple #21
0
 def get_address_from_view_page(self, index):
     wd = self.app.wd
     self.open_home_page()
     wd.find_elements_by_css_selector('img[alt="Details"]')[index].click()
     text = wd.find_element_by_id("content").text
     home = re.search("H: (.*)", text).group(1)
     work = re.search("W: (.*)", text).group(1)
     mobile = re.search("M: (.*)", text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return Address(home=home,
                    work=work,
                    mobile=mobile,
                    secondaryphone=secondaryphone)
Exemple #22
0
def test_delete_first_group(app, db):
    old_addresses = db.get_address_list()
    if len(db.get_address_list()) == 0:
        app.address.create(
            Address(first_name="Fname for deleting",
                    midle_name="Mname for deleting"))
        app.address.submit()
    address = random.choice(old_addresses)
    app.address.delete_address_by_id(address.id)
    assert len(old_addresses) - 1 == app.address.count()
    new_addresses = db.get_address_list()
    old_addresses.remove(address)
    assert old_addresses == new_addresses
def get_tag_items_direct():
    """
    Returns all used tag items as set. Directly from the Address model.
    """

    tag_items = set()

    query = Address.query(projection = [Address.tag_items], distinct = True)
    for address in query.iter(batch_size = 200):
        for tag_item in address.tag_items:
            tag_items.add(tag_item)

    # Finished
    return tag_items
def get_business_items_direct():
    """
    Returns all used business items as set. Directly from the Address model.
    """

    business_items = set()

    query = Address.query(projection=[Address.business_items], distinct=True)
    for address in query.iter(batch_size=200):
        for business_item in address.business_items:
            business_items.add(business_item)

    # Finished
    return business_items
def get_tag_items_direct():
    """
    Returns all used tag items as set. Directly from the Address model.
    """

    tag_items = set()

    query = Address.query(projection=[Address.tag_items], distinct=True)
    for address in query.iter(batch_size=200):
        for tag_item in address.tag_items:
            tag_items.add(tag_item)

    # Finished
    return tag_items
Exemple #26
0
 def get_address_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute("SELECT id, firstname, lastname, address, home, mobile, work, phone2, email, email2, email3 "
                        "FROM addressbook WHERE deprecated='0000-00-00 00:00:00'")
         for row in cursor:
             (id, firstname, lastname, address, home, mobile, work, phone2, email, email2, email3) = row
             list.append(Address(id=str(id), firstname=firstname, lastname=lastname, address=address,
                                 homephone=home, mobile=mobile, workphone=work, secondaryphone=phone2,
                                 email=email, email2=email2, email3=email3))
     finally:
         cursor.close()
     return list
Exemple #27
0
def test_delete_some_address(app, db, check_ui):
    if len(db.get_address_list()) == 0:
        app.address.new(
            Address(first_name="test", middle_name="test", last_name="test"))
    old_addresses = db.get_address_list()
    address = random.choice(old_addresses)
    app.address.delete_address_by_id(address.id)
    new_addresses = db.get_address_list()
    assert len(old_addresses) - 1 == len(new_addresses)
    old_addresses.remove(address)
    assert old_addresses == new_addresses
    if check_ui:
        assert sorted(new_addresses, key=Address.id_or_max) == sorted(
            app.address.get_address_list(), key=Address.id_or_max)
def test_modify_address_firstname(app, db, check_ui):
    if app.address.count() == 0:
        app.address.create(Address(lastname='test'))
    old_address = db.get_address_list()
    text = "8999"
    address = random.choice(old_address)
    index = old_address.index(address)
    address.firstname = text
    app.address.modify_address_by_id(address.id, address)
    new_address = db.get_address_list()
    assert len(old_address) == len(new_address)
    old_address[index] = address
    assert sorted(old_address, key=Address.id_or_max) == sorted(new_address, key=Address.id_or_max)
    if check_ui:
        assert sorted(new_address, key=Address.id_or_max) == sorted(app.address.get_address_list(), key=Address.id_or_max)
Exemple #29
0
def updateCustomer(customerid):
    if not request.json:
        abort(400)
    if not 'name' in request.json or not 'address' in request.json:
        abort(400)
    address = Address(request.json['address']['line'],
                      request.json['address']['city'],
                      request.json['address']['state'],
                      request.json['address']['zip'])
    customer = Customer(customerid, request.json['name'], address)
    ##Update the Customer
    ##send CustomerUpdated event
    customerEventData = CustomerChanged(customer)
    postToEventStore('CustomerUpdated', customerEventData)
    return jsonify(customer), 200
Exemple #30
0
 def get_kontakt_list(self):
     if self.kontakt_cash is None:
         wd = self.app.wd
         self.home_page()
         self.kontakt_cash = []
         for tr in wd.find_elements_by_css_selector("table tr"):
             row = tr.find_elements_by_css_selector("td")
             if not len(row):
                 continue
             self.kontakt_cash.append(
                 Address(lastname=row[1].text,
                         firstname=row[2].text,
                         id=row[0].find_element_by_css_selector(
                             "input").get_attribute('value')))
     return list(self.kontakt_cash)
def get_category_items_direct():
    """
    Returns all used category items as set. Directly from the Address model.
    """

    category_items = set()

    query = Address.query(projection = [Address.category_items], distinct = True)
    for address in query.iter(batch_size = 200):

        for category_item in address.category_items:
            category_items.add(category_item)

    # Finished
    return category_items
Exemple #32
0
def get_category_items_direct():
    """
    Returns all used category items as set. Directly from the Address model.
    """

    category_items = set()

    query = Address.query(projection=[Address.category_items], distinct=True)
    for address in query.iter(batch_size=200):

        for category_item in address.category_items:
            category_items.add(category_item)

    # Finished
    return category_items