コード例 #1
0
 def if_default_postal_data(self, number_div):
     name = user_data.find_element_by_xpath("div[" + str(number_div) +
                                            "]").text
     street = self.split_string_by_comma(
         user_data.find_element_by_xpath("div[" + str(number_div + 1) +
                                         "]").text, 1)
     num_house = self.split_string_by_comma(
         user_data.find_element_by_xpath("div[" + str(number_div + 1) +
                                         "]").text, 0)
     city = self.split_string_by_comma(
         user_data.find_element_by_xpath("div[" + str(number_div + 2) +
                                         "]").text, 0)
     state = self.split_string_by_comma(
         user_data.find_element_by_xpath("div[" + str(number_div + 2) +
                                         "]").text, 1)
     zip = self.split_string_by_comma(
         user_data.find_element_by_xpath("div[" + str(number_div + 2) +
                                         "]").text, 2)
     country = self.split_string_by_comma(
         user_data.find_element_by_xpath("div[" + str(number_div + 3) +
                                         "]").text, 0)
     phone = self.split_phone_number(
         user_data.find_element_by_xpath("div[" + str(number_div + 4) +
                                         "]").text, 1)
     return Postaldata(name=name,
                       street=street,
                       num_house=num_house,
                       city=city,
                       state=state,
                       zip=zip,
                       country=country,
                       phone=phone)
コード例 #2
0
def test_add_req_user_data(app):
    app.session.log_in(username="******", password="******")
    app.fill_in_user_data_form(
        Postaldata(country="Ukraine",
                   name="Ilyk Stepan",
                   street="Lazarenka str",
                   num_house="23",
                   city="Lviv",
                   state="Lviv reg",
                   zip="82100",
                   phone="0938211673"))
    app.session.log_out()
コード例 #3
0
def test_modify_first_user_data(app, postaldata):
    app.postaldata.make_postaldata_quantity(5, Postaldata(country="Ukraine", name=rand_str("name", 8), street=rand_str("street", 8),
                                                                          num_house=rand_str("num", 8), city=rand_str("city", 8), state=rand_str("state", 8),
                                                                          zip=int(random.randint(10000, 99000)), phone=rand_str("phone", 8)))
    old_postaldata_list = app.postaldata.count_postal_data_object_list()
    index_postal_data = randrange(0, len(old_postaldata_list), 1)
    new_postaldata = postaldata
    app.postaldata.modify_postaldata_street_by_index(new_postaldata, index_postal_data)
    new_postaldata_list = app.postaldata.count_postal_data_object_list()
    assert len(old_postaldata_list) == len(new_postaldata_list)
    assert new_postaldata in new_postaldata_list
    #assert old_postaldata_list[index_postal_data] in new_postaldata_list == False
コード例 #4
0
def test_del_some_user_data(app, execution_number):
    app.postaldata.make_postaldata_quantity(execution_number, Postaldata(country="Ukraine", name=rand_str("name", 8),
                                                       street=rand_str("street", 8), num_house=rand_str("num", 8), city=rand_str("city", 8),
                                                       state=rand_str("state", 8), zip=int(random.randint(10000, 99000)), phone=rand_str("phone", 8)))
    old_postaldata_list = app.postaldata.count_postal_data_object_list()
    index_postal_data = randrange(0, len(old_postaldata_list), 1)
    deleted_postaldata = old_postaldata_list[index_postal_data]
    app.postaldata.delete_user_data_by_index(index_postal_data)
    new_postaldata_list = app.postaldata.count_postal_data_object_list()
    assert len(old_postaldata_list) == len(new_postaldata_list) + 1
    old_postaldata_list[index_postal_data:index_postal_data+1] = []
    assert old_postaldata_list == new_postaldata_list
    #assert (deleted_postaldata in new_postaldata_list) == False
コード例 #5
0
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


country = ["Albania"
           for i in range(n)] + ["American Samoa" for i in range(n)] + [
               "Aruba" for i in range(n)
           ] + ["Ukraine"
                for i in range(n)] + ["Austria" for i in range(n)
                                      ] + ["Nigeria" for i in range(n)]

#[Postaldata(country="Algeria", name="Jhon Travolta", street="Shev4enka str", num_house="12", city="Drogobych",state="Lviv reg", zip=12300, phone="0978339274")] +

testdata = [
    Postaldata(country=country[random.randint(0, len(country))],
               name=rand_str("name", 5),
               street=rand_str("street", 5),
               num_house=rand_str("num", 5),
               city=rand_str("city", 5),
               state=rand_str("state", 5),
               zip=int(random.randint(10000, 99000)),
               phone=rand_str("phone", 5)) for i in range(n)
]

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

with open(postal_data_file, "w") as out:
    jsonpickle.set_encoder_options("json", indent=2)
    out.write(jsonpickle.encode(testdata))

#getopt — Parser for command line options where to read https://docs.python.org/3.1/library/getopt.html -n 10 -f data/test1.json
コード例 #6
0
from model.postaldata import Postaldata
import random
import string
import jsonpickle
import os.path

constant = [
    Postaldata(country="Albania",
               name="Jhon Travolta",
               street="Shev4enka str",
               num_house="12",
               city="Drogobych",
               state="Lviv reg",
               zip="12300",
               phone="0978339274"),
    Postaldata(country="Albania",
               name="Jhon Travolta2",
               street="Shev4enka2 str",
               num_house="123",
               city="Drogobych2",
               state="Lviv reg2",
               zip="12301",
               phone="09783392742")
]


def rand_str(prefix, maxlen):
    symbols = string.ascii_letters + string.digits
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])
コード例 #7
0
 def modify_first_postaldata_street(self):
     """unnecessary method"""
     self.modify_postaldata_street_by_index(
         Postaldata(country="Ukraine",
                    street="Lazarenka str newnew new new"), 0)
コード例 #8
0
from model.postaldata import Postaldata
from random import randrange
import pytest
import random
import string

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

testdata = [Postaldata(country="Ukraine", name=rand_str("name", 5), street=rand_str("street", 5), num_house=rand_str("num", 5), city=rand_str("city", 5), state=rand_str("state", 5), zip=int(random.randint(10000, 99000)), phone=rand_str("phone", 5)) for i in range(5)]


@pytest.mark.parametrize('execution_number', range(1,8))
def test_del_some_user_data(app, execution_number):
    app.postaldata.make_postaldata_quantity(execution_number, Postaldata(country="Ukraine", name=rand_str("name", 8),
                                                       street=rand_str("street", 8), num_house=rand_str("num", 8), city=rand_str("city", 8),
                                                       state=rand_str("state", 8), zip=int(random.randint(10000, 99000)), phone=rand_str("phone", 8)))
    old_postaldata_list = app.postaldata.count_postal_data_object_list()
    index_postal_data = randrange(0, len(old_postaldata_list), 1)
    deleted_postaldata = old_postaldata_list[index_postal_data]
    app.postaldata.delete_user_data_by_index(index_postal_data)
    new_postaldata_list = app.postaldata.count_postal_data_object_list()
    assert len(old_postaldata_list) == len(new_postaldata_list) + 1
    old_postaldata_list[index_postal_data:index_postal_data+1] = []
    assert old_postaldata_list == new_postaldata_list
    #assert (deleted_postaldata in new_postaldata_list) == False