Ejemplo n.º 1
0
class Addressbook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self,config="target.json", browser="chrome"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(_file_)), "..", config)
        with open(config_file) as f:
            self.target = json.load(f)



    def init_fixtures(self):
        web_config = self.target ['web']
        self.fixture = Application(browser=self.browser, base_url=web_config('baseUrl'))
        self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'],
                              password=db_config['password'])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()


    def create_group(self, name, header, footer):
            self.fixture.group.create(Group(name=name, header=header, footer=footer))
Ejemplo n.º 2
0
def app(request):
    base_url = request.config.getoption("--base_url")
    fixture = Application(base_url)
    fixture.wd.maximize_window()
    fixture.wd.implicitly_wait(10)
    yield fixture
    fixture.destroy()
Ejemplo n.º 3
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="Chrome"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser, base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host = db_config['host'], name = db_config['name'], user = db_config['user'], password = db_config['password'])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)
Ejemplo n.º 4
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="firefox"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser, base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def modify_group(self, source_group, new_data_group):
        self.fixture.group.modify_group_by_id(source_group.id, new_data_group)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)

    def new_contact(self, lastname, firstname, address, home, mobile, work, phone2, email, email2, email3):
        return Contact(lastname=lastname, firstname=firstname, address=address,
                   home=home, mobile=mobile, work=work, phone2=phone2,
                   email=email, email2=email2, email3=email3)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def add_contact(self, contact):
        self.fixture.contact.add(contact)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)
        self.fixture.wd.implicitly_wait(5)

    def modify_contact(self, source_contact, new_data_contact):
        self.fixture.contact.modify_contact_by_id(source_contact.id, new_data_contact)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_max) == sorted(list2, key=Contact.id_or_max)
Ejemplo n.º 5
0
def app(request):
    base_url = request.config.getoption("--base-url")
    allure_dir = request.config.getoption("--report-folder")
    fixture = Application(base_url, allure_dir)
    fixture.wd.implicitly_wait(10)
    fixture.wd.maximize_window()
    yield fixture
    fixture.destroy()
Ejemplo n.º 6
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST_SUITE'

    def __init__(self, config='target.json', browser='chrome'):
        self.browser = browser
        path_to_config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', config)
        with open(path_to_config_file) as config_file:
            self.target = json.load(config_file)

    def init_fixtures(self):
        self.fixture = Application(browser=self.browser, base_url=self.target['web']['baseUrl'])
        self.fixture.session.check_login(username=self.target['web']['username'], password=self.target['web']['password'])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.dbfixture.destroy()

# GROUPS

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def create_group(self, group):
        self.fixture.group.create(group)

    def get_group_list(self):
        return self.dbfixture.get_groups_list()

    def group_lists_should_be_equal(self, old_list, new_list):
        assert sorted(old_list, key=Group.sorting_id_or_maxsize) == sorted(new_list, key=Group.sorting_id_or_maxsize)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

# CONTACTS

    def new_contact(self, firstname, lastname):
        return Contact(firstname=firstname, lastname=lastname)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def get_contact_list(self):
        return self.dbfixture.get_contacts_list()

    def contact_lists_should_be_equal(self, old_list, new_list):
        assert sorted(old_list, key=Contact.sorting_id_or_maxsize) == sorted(new_list, key=Contact.sorting_id_or_maxsize)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def modify_contact(self, contact, new_contact):
        new_contact.id = contact.id  # чтоб в изм. контакте был заданный id, не None. А то будут проблемы при сортировке
        self.fixture.contact.modify_contact_by_id(contact.id, new_contact)
Ejemplo n.º 7
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config = 'target.json', browser='firefox'):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target["web"]
        self.fixture = Application(browser=self.browser, base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
        db_config = self.target["db"]
        self.dbfixture = DbFixture(host=db_config["host"], name=db_config["name"], user=db_config["user"], password=db_config["password"])

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.dbfixture.destroy()

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def new_contact(self, firstname, lastname):
        return Contact(firstname=firstname, lastname=lastname)

    def create_group(self, group):
        self.fixture.group.create(group)

    def create_contact(self, contact):
        self.fixture.contact.add_new(contact)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def change_contact_name(self, contact, new_name):
        edited_contact = contact
        edited_contact.firstname = new_name
        self.fixture.contact.edit_contact_by_id(edited_contact, contact.id)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_max) == sorted(list2, key=Contact.id_or_max)
Ejemplo n.º 8
0
class ContactBook:
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_name = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_name) as config_file:
            self.target = json.load(config_file)

    def init_fixtures(self):
        web_config = self.target["web"]
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target["db"]
        self.dbfixture = ORMFixture(host=db_config["host"],
                                    name=db_config["name"],
                                    user=db_config["user"],
                                    password=db_config["password"])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_contact(self, firstname, lastname):
        return Contact(first_name=firstname, last_name=lastname)

    def create_contact(self, contact):
        self.fixture.contact.add_new(contact)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def update_contact(self, contact_old, contact_new):
        self.fixture.contact.update_contact_by_id(contact_new, contact_old.id)

    def update_value_in_list(self, contact_list, contact_to_update,
                             contact_with_new_data):
        # NOTE: this action is based on the shallow copying of the objects and greatly on immutability
        contact = contact_list[contact_list.index(contact_to_update)]
        contact.first_name = contact_with_new_data.first_name
        contact.last_name = contact_with_new_data.last_name
Ejemplo n.º 9
0
class Projects:
    def __init__(self, browser='chrome', config='target.json'):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config['baseURL'])
        pass

    def destroy_fixtures(self):
        self.fixture.destroy()

    def create_project(self, name, description):
        self.fixture.project.create(Project(name=name,
                                            description=description))
Ejemplo n.º 10
0
class UntitledTestCase(unittest.TestCase):
    def setUp(self):
        self.app = Application()
        self.test = ''

    def test_untitled_test_case_delete(self):
        print('test_untitled_test_case_delete_START')
        self.app.session.method_login(username="******", password="******")
        # self.app.product.create(Group(product_name="Product_110", product_code="Code_110"))
        self.app.product.delete()
        self.test = 'test_untitled_test_case_delete'

    # def test_untitled_test_case31(self):
    #     print('test_untitled_test_case31_START')
    #     self.app.session.method_login(username="******", password="******")
    #     self.app.product.create(Group(product_name="Product_104", product_code="Code_104"))
    #     self.test = 'test_untitled_test_case31'

    def tearDown(self):
        print(self.test + '_END')
        self.app.destroy()
Ejemplo n.º 11
0
class AddressBook:
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="firefox"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser, baseurl=web_config['baseurl'])
        self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'],
                                   password=db_config['password'])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_contact(self, firstname, lastname):
        return Contact(firstname=firstname, lastname=lastname)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)
        time.sleep(0.1)

    def modify_contact(self, contact, new_contact):
        self.fixture.contact.modify_contact_by_id(contact.id, new_contact)
        time.sleep(0.1)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_max) == sorted(list2, key=Contact.id_or_max)
Ejemplo n.º 12
0
class addressbook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json"):
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)
        with open(config_file) as config:
            self.target = json.load(config)

    def init_fixtures(self):
        web_config = self.target["web"]
        self.fixture = Application(baseurl=web_config["baseURL"])
        self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
        db_config = self.target["db"]
        self.db_fixture = DBFixture(host=db_config["host"], database=db_config["name"], user=db_config["user"],
                               password=db_config["password"])

    def get_contacts(self):
        return self.db_fixture.get_contacts()

    def new_contact(self, firstname, lastname):
        return Contact(firstname=firstname, lastname=lastname)

    def contacts_should_be_equal(self, old_contacts, new_contacts):
        assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max)

    def add(self, contact):
        self.fixture.contact.add(contact)

    def delete(self, contact):
        self.fixture.contact.delete_by_id(contact.id)

    def update(self, contact, data):
        self.fixture.contact.update_by_id(contact.id, data)

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.db_fixture.destroy()
Ejemplo n.º 13
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)
        with open(config_file_path) as f:
            self.target = json.load(f)

    def init_fixture(self):
        web_config = self.target["web"]
        self.fixture = Application(browser=self.browser, base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
        db_config = self.target["db"]
        self.dbfixture = DbFixture(host=db_config["host"], name=db_config["name"], user=db_config["user"],
                                   password=db_config["password"])

    def destroy_fixture(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)
Ejemplo n.º 14
0
class AddressBook:
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixture(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config['username'],
                                          password=web_config['password'])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'],
                                   name=db_config['database'],
                                   user=db_config['user'],
                                   password=db_config['password'])

    def destroy_fixture(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, firstname, middlename, lastname, nickname, title,
                    company, address, home, mobile, work, fax, email, email2,
                    email3, homepage, address2, phone2, notes, bday, bmonth,
                    byear, aday, amonth, ayear):
        return Contact(firstname=firstname,
                       middlename=middlename,
                       lastname=lastname,
                       nickname=nickname,
                       title=title,
                       company=company,
                       address1=address,
                       homephone=home,
                       mobilephone=mobile,
                       workphone=work,
                       fax=fax,
                       email1=email,
                       email2=email2,
                       email3=email3,
                       homepage=homepage,
                       bdaydate=bday,
                       bmonth=bmonth,
                       aday=aday,
                       amonth=amonth,
                       byear=byear,
                       ayear=ayear,
                       address2=address2,
                       phone2=phone2,
                       notes1=notes)

    def create_contact(self, contact):
        self.fixture.contact.add_new_contact()
        self.fixture.contact.fill_data(contact)
        self.fixture.contact.submit()

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def edit_contact(self, contact):
        self.fixture.contact.edit_contact_by_id(contact.id)

    def edited_contact(self, firstname, middlename, lastname, nickname, title,
                       company, address, home, mobile, work, fax, email,
                       email2, email3, homepage, address2, phone2, notes, bday,
                       bmonth, byear, aday, amonth, ayear):
        return Contact(firstname=firstname,
                       middlename=middlename,
                       lastname=lastname,
                       nickname=nickname,
                       title=title,
                       company=company,
                       address1=address,
                       homephone=home,
                       mobilephone=mobile,
                       workphone=work,
                       fax=fax,
                       email1=email,
                       email2=email2,
                       email3=email3,
                       homepage=homepage,
                       bdaydate=bday,
                       bmonth=bmonth,
                       aday=aday,
                       amonth=amonth,
                       byear=byear,
                       ayear=ayear,
                       address2=address2,
                       phone2=phone2,
                       notes1=notes)

    def update_contact(self, contact):
        self.fixture.contact.fill_data(contact)
        self.fixture.contact.update()
        time.sleep(5)

    def update_old_list(self, old_contact, contact):
        for i in old_contact:
            if i.id == contact.id:
                i.firstname = contact.firstname
                i.lastname = contact.lastname
        return old_contact
Ejemplo n.º 15
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'],
                                   name=db_config['name'],
                                   user=db_config['user'],
                                   password=db_config['password'])

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.dbfixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def new_group_for_modify(self, name, header, footer, id):
        return Group(name=name, header=header, footer=footer, id=id)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def get_group_id(self, group):
        return group.id

    def get_contact_id(self, contact):
        return contact.id

    def modify_group(self, group1, group2):
        self.fixture.group.modify_group_by_id(group1.id, group2)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def verify_group_list_is_not_empty(self, list1):
        if len(list1) == 0:
            self.fixture.group.create(Group(name="New_group"))

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, firstname, lastname, address):
        return Contact(firstname=firstname, lastname=lastname, address=address)

    def new_contact_for_modify(self, firstname, lastname, address, id):
        return Contact(firstname=firstname,
                       lastname=lastname,
                       address=address,
                       id=id)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def verify_contact_list_is_not_empty(self, list1):
        if len(list1) == 0:
            self.fixture.contact.create(
                Contact(firstname="firstname4",
                        lastname="lastname4",
                        address="adress4"))

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def modify_contact(self, contact1, contact2):
        self.fixture.contact.modify_contact_by_id(contact1.id, contact2)
Ejemplo n.º 16
0
class AddressBook:
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config['username'],
                                          password=web_config['password'])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'],
                                   name=db_config['name'],
                                   user=db_config['user'],
                                   password=db_config['password'])

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.dbfixture.destroy()

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def group_list_should_be_equals(self, list1, list2):
        def clear(group):
            return Group(id=group.id,
                         name=re.sub(" +", " ", group.name).strip())

        assert sorted(map(clear, list1),
                      key=Group.id_or_max) == sorted(map(clear, list2),
                                                     key=Group.id_or_max)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, firstname, middlename, lastname):
        return Contact(firstname=firstname,
                       middlename=middlename,
                       lastname=lastname)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def contact_list_should_be_equals(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def get_non_empty_contact_list(self):
        if len(self.dbfixture.get_contact_list()) == 0:
            self.fixture.contact.create(
                Contact(firstname="Name",
                        middlename="Middle",
                        lastname="Surname"))
        return self.dbfixture.get_contact_list()

    def modify_contact(self, random_contact, new_contact):
        self.fixture.contact.modify_contact_by_id(new_contact,
                                                  random_contact.id)
Ejemplo n.º 17
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser='firefox'):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   '..', config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'],
                                   name=db_config['name'],
                                   user=db_config['user'],
                                   password=db_config['password'])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def edit_group(self, random_group, edit_group):
        edit_group.id = random_group.id
        self.fixture.group.edit_group_by_id(edit_group.id, edit_group)

    def replace_values_list(self, old_list, index, edit_value):
        old_list[index] = edit_value

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self,
                    firstname='name_123',
                    lastname='name_456',
                    mobile='789'):
        return Contact(firstname=firstname, lastname=lastname, mobile=mobile)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def edit_contact(self, random_contact, edit_contact):
        edit_contact.id = random_contact.id
        self.fixture.contact.edit_contact_by_id(edit_contact.id, edit_contact)
Ejemplo n.º 18
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_URL=web_config['baseURL'])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'],
                                   name=db_config['name'],
                                   user=db_config['user'],
                                   password=db_config['password'])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.identifier)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, firstname1, middlename1, lastname1):
        return Contact(firstname=firstname1,
                       middlename=middlename1,
                       lastname=lastname1)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)
        print(list1, list2)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.identifier)

    def edit_contact(self, contact, new_contact_data):
        self.fixture.contact.edit_contact_by_id(contact.identifier,
                                                new_contact_data)
Ejemplo n.º 19
0
def app(request):
    fixture = Application()
    request.addfinalizer(fixture.destroy())
    return fixture
Ejemplo n.º 20
0
class Addressbook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="config.json", browser="chrome"):
        self.browser = browser
        conf = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)
        with open(conf) as f:
            self.config = json.load(f)

    def init_fixtures(self):
        web_config = self.config['web']
        self.fixture = Application(browser=self.browser, baseURL=web_config["baseURL"])
        self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
        db_config = self.config['db']
        self.dbfixture = ORMFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])

    def destroy_fixtures(self):
        #self.dbfixture.destroy
        self.fixture.destroy()

    def create_group(self, group):
        self.fixture.group.create(group)

    def get_group_list(self):
        return self.dbfixture.get_list_groups()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def edit_group(self, random_group, edit_group):
        edit_group.id = random_group.id
        self.fixture.group.edit_group_by_id(edit_group)

    def replace_values_list(self, old_list, index, edit_value):
        old_list[index] = edit_value

    def get_contact_list(self):
        return self.dbfixture.get_list_contacts()

    def new_contact(self, firstname=None, lastname=None, middlename=None, nickname=None, title=None, company=None,
                    address=None, email2=None, email3=None, work_phone=None, mobile_phone=None, home_phone=None, fax=None,
                    homepage=None, notes=None, phone2=None, address2=None):
        return Contact(firstname=firstname, middlename=middlename, lastname=lastname, nickname=nickname, title=title,
                       company=company, address1=address, home_phone=home_phone, mobile_phone=mobile_phone,
                       work_phone=work_phone, fax=fax, email2=email2, email3=email3, homepage=homepage,
                       address2=address2, phone2=phone2, notes=notes)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_max) == sorted(list2, key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def edit_contact(self, random_contact, edit_contact):
        edit_contact.id = random_contact.id
        self.fixture.contact.edit_contact_by_id(edit_contact)
Ejemplo n.º 21
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config='target.json', browser='chrome'):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target["web"]
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target["db"]
        self.dbfixture = DbFixture(host=db_config["host"],
                                   name=db_config["name"],
                                   user=db_config["user"],
                                   password=db_config["password"])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, firstname, lastname, address, home, mobile):
        return Contact(firstname=firstname,
                       lastname=lastname,
                       address=address,
                       home=home,
                       mobile=mobile)

    def new_contact_data(self, id, firstname, lastname, address, home, mobile):
        return Contact(id=id,
                       firstname=firstname,
                       lastname=lastname,
                       address=address,
                       home=home,
                       mobile=mobile)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def edit_contact(self, contact, contact_data):
        self.fixture.contact.edit_contact_by_id(contact.id, contact_data)

    def delete_contact(self, contact):
        self.fixture.contact.delete_by_id_from_edit_form(contact.id)
Ejemplo n.º 22
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST_SUITE'

    def __init__(self, config='target.json', browser='chrome'):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   '..', config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config['baseUrl'],
                                   host_ip=web_config['hostip'])
        self.fixture.session.ensure_login(username=web_config['username'],
                                          password=web_config['password'])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'],
                                   name=db_config['name'],
                                   user=db_config['user'],
                                   password=db_config['password'])

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.dbfixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def group_lists_should_be_equal(self, new_list, old_list):
        assert sorted(old_list,
                      key=Group.id_or_max) == sorted(new_list,
                                                     key=Group.id_or_max)

    def new_contact(self, firstname, lastname):
        return Contact(firstname=firstname, lastname=lastname)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def create_contact(self, contact):
        self.fixture.contact.create_contact(contact)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)
        time.sleep(4)

    def modify_contact(self, contact):
        self.fixture.contact.modify_contact_by_id(contact.id, contact)

    def contact_lists_should_be_equal(self, new_list, old_list):
        assert sorted(old_list,
                      key=Contact.id_or_max) == sorted(new_list,
                                                       key=Contact.id_or_max)
Ejemplo n.º 23
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="firefox"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   baseURL=web_config['baseURL'])
        db_config = self.target['db']
        self.dbfixture = DBficture(host=db_config['host'],
                                   name=db_config['name'],
                                   user=db_config['user'],
                                   password=db_config['password'])
        self.fixture.session.ensure_login(username=web_config['username'],
                                          password=web_config['password'])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def new_contact(self, First_name, Middle_name, Last_name, Nickname, Title,
                    Company, Address, Home, Mobile, Work, Fax, E_mail, E_mail2,
                    E_mail3, Homepage, Birthday_day, Birthday_month,
                    Birthday_year, Anniversary_day, Anniversary_month,
                    Anniversary_year, Address_Secondary, Home_Secondary,
                    Notes):
        return Contact(First_name=First_name,
                       Middle_name=Middle_name,
                       Last_name=Last_name,
                       Nickname=Nickname,
                       Title=Title,
                       Company=Company,
                       Address=Address,
                       Home=Home,
                       Mobile=Mobile,
                       Work=Work,
                       Fax=Fax,
                       E_mail=E_mail,
                       E_mail2=E_mail2,
                       E_mail3=E_mail3,
                       Homepage=Homepage,
                       Birthday_day=Birthday_day,
                       Birthday_month=Birthday_month,
                       Birthday_year=Birthday_year,
                       Anniversary_day=Anniversary_day,
                       Anniversary_month=Anniversary_month,
                       Anniversary_year=Anniversary_year,
                       Address_Secondary=Address_Secondary,
                       Home_Secondary=Home_Secondary,
                       Notes=Notes)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def delete_group(self, group):
        self.fixture.group.delete_by_id(group.id)

    def delete_contact(self, contact):
        self.fixture.contact.delete_by_id(contact.id)

    def edit_group(self, group, new_group_data):
        new_group_data.id = group.id
        self.fixture.group.edit_by_id(new_group_data)

    def edit_contact(self, contact, new_contact_data):
        new_contact_data.id = contact.id
        self.fixture.contact.edit_by_id(new_contact_data)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)
Ejemplo n.º 24
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target['db']
        self.dbFixture = DbFixture(host=db_config["host"],
                                   name=db_config["name"],
                                   user=db_config["user"],
                                   password=db_config["password"])

    def destroy_fixtures(self):
        self.dbFixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbFixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def new_contact(self, firstname, middlename, lastname, nickname, title,
                    company, address, fax, mobilephone, workphone, homephone,
                    email, email2, email3, homepage, option1, option2, byear,
                    option3, option4, ayear, address2, secondaryphone, notes):
        return Contact(firstname=firstname,
                       middlename=middlename,
                       lastname=lastname,
                       nickname=nickname,
                       title=title,
                       company=company,
                       address=address,
                       fax=fax,
                       mobilephone=mobilephone,
                       workphone=workphone,
                       homephone=homephone,
                       email=email,
                       email2=email2,
                       email3=email3,
                       homepage=homepage,
                       option1=option1,
                       option2=option2,
                       byear=byear,
                       option3=option3,
                       option4=option4,
                       ayear=ayear,
                       address2=address2,
                       secondaryphone=secondaryphone,
                       notes=notes)

    def get_contact_list(self):
        return self.dbFixture.get_contact_list()

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def edit_contact(self, contact, new_contact):
        self.fixture.contact.edit_contact_by_id(contact.id, new_contact)

    def fix_new_contact_id(self, contact, new_contact):
        new_contact.id = contact.id
        return new_contact

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)
Ejemplo n.º 25
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config_file="target.json", browser="firefox"):
        self.browser = browser

        config = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config_file)
        with open(config_file) as config:
            self.target = json.load(config)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser, base_url=web_config['baseUrl'])

        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'],
                                   user=db_config['user'], password=db_config['password'])

        self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.dbfixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    # Group methods
    def get_group_list(self):
        return self.dbfixture.get_group_list()

    # TODO: try to implement single method which can be used
    # to choose both groups and contacts
    def choose_group_from_list(self, groups):
        return random.choice(groups)

    def create_group(self, group):
        self.fixture.groups.create(group)

    def delete_group(self, group):
        self.fixture.groups.delete_group_by_id(group.id)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_maxval) == sorted(list2, key=Group.id_or_maxval)

    # Contact methods
    def get_contacts_list(self):
        return self.dbfixture.get_contacts_list()

    # TODO: try to implement single method which can be used
    # to choose both groups and contacts
    def choose_contact_from_list(self, contacts):
        return random.choice(contacts)

    def new_contact(self):
        return contact_with_rnd_data

    def create_contact(self, contact):
        self.fixture.contacts.create(contact)

    def delete_contact(self, contact):
        self.fixture.contacts.delete_contact_by_id(contact.id)

    def modify_contact(self, contact_to_modify, new_contact_data):
        new_contact_data.id = contact_to_modify.id
        # Save contact we got after entering data on edit form.
        # This is necessary for cases when we don't change
        # some of fields.
        return self.fixture.contacts.edit_contact_by_id(new_contact_data)

    def contacts_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_maxval) == sorted(list2, key=Contact.id_or_maxval)
Ejemplo n.º 26
0
def app():
    # with allure.step('Running browser'):
    fixture = Application()
    yield fixture
    # with allure.step('Stopping browser'):
    fixture.destroy()
Ejemplo n.º 27
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'                                      # Едиый объект для всего тестового набора

    def __init__(self, config="target.json", browser="firefox"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)    # Определение пути к конфигурационному файлу по умолчанию
        with open(config_file) as f:                                        # Открыть файл, контроль автоматического закрытия после выполнения блока команд
            self.target = json.load(f)                                      # Загрузка данных из файла

    # Инициализация (создание) фикстур
    def init_fixtures(self):
        web_config = self.target["web"]                                     # Получение данных конфигурации выполнения из файла для работы с Web
        self.fixture = Application(browser=self.browser, base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password']) # Авторизация пользователя
        db_config = self.target['db']                                       # Получение данных конфигурации выполнения из файла для работы с базой данных
        self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])   # Создание фикстуры работы с базой данных
        orm_config = self.target['db']                                      # Получение данных конфигурации выполнения из файла для работы с базой данных
        self.ormfixture = ORMFixture(host=orm_config['host'], name=orm_config['name'], user=orm_config['user'], password=orm_config['password'])   # Создание фикстуры работы с базой данных

    # Уничтожение фикстур
    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()
        self.ormfixture.destroy()

    # Определение контакта
    def new_address(self, first_name, middle_name, last_name, address):
        return Address(first_name=first_name, middle_name=middle_name, last_name=last_name, address=address)    # Контакт

    # Переопределение контакта по идетфикатору
    def new_address_with_id(self, id, first_name, middle_name, last_name, address):
        return Address(id=id, first_name=first_name, middle_name=middle_name, last_name=last_name, address=address)    # Контакт

    # Получение идентификатора контакта из списка по его номеру
    def get_address_id_by_index_from_the_list(self, index, address_list):
        return address_list[index].id                                       # Тдентификатор контакта

    # Получение списка контактов
    def get_address_list(self):
        return self.ormfixture.get_address_list()                           # Список контактов

    # Получение непустого списка контактов
    def get_not_empty_address_list(self):
        if len(self.ormfixture.get_address_list()) == 0:                    # Проверка наличия хотябы одного контакта в списке
            self.fixture.address.create(Address(first_name="Михаил", middle_name="Алексеевич", last_name="Новиков", nickname="M.Novikov", title="Title", company="КБ ДОРС", address="Федеративный пр. д.15 к.4", tel_home="001-13-59", tel_mobile="002-13-59", tel_work="003-13-59", tel_fax="004-13-59", web_email="*****@*****.**", web_email2="*****@*****.**", web_email3="*****@*****.**", web_homepage="http://software-testing.ru", birthday_day=14, birthday_month=11, birthday_year="1986", anniversary_day=1, anniversary_month=1, anniversary_year="2000", sec_address="Secondary Address", home="Home", notes="Notes"))    # Создание контакта на случай пустого списка
        return self.get_address_list()                                      # Список контактов

    # Создание контакта
    def create_address(self, address):
        self.fixture.address.create(address)                                # Создание нового контакта

    # Удаление контакта
    def delete_address(self, address):
        self.fixture.address.delete_address_by_id(address.id)               # Удаление контакта по идентификатору

    # Изменение контакта
    def modify_address(self, address):
        self.fixture.address.modify_address_by_id(address)                  # Изменение контакта по идентификатору

    # Проверка равенства списков контактов
    def address_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Address.id_or_max) == sorted(list2, key=Address.id_or_max) # Сравнение сортированных по идентификатору списков контактов
Ejemplo n.º 28
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="firefox"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_file) as f:
            self.target = json.load(f)

    def init_fixtures(self):
        web_config = self.target['web']
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target['db']
        self.dbfixture = DbFixture(host=db_config["host"],
                                   name=db_config["name"],
                                   user=db_config["user"],
                                   password=db_config["password"])

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.dbfixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def new_groupWithID(self, group, name, header, footer):
        return Group(id=group.id, name=name, header=header, footer=footer)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def create_group(self, group):
        self.fixture.group.create(group)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def modify_group(self, group):
        self.fixture.group.change_group_by_id(group.id, group)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, lastname, firstname, address, email, email2, email3,
                    home_phone, mobile_phone, work_phone, phone2):
        return Contact(lastname=lastname,
                       firstname=firstname,
                       address=address,
                       email=email,
                       email2=email2,
                       email3=email3,
                       home_phone=home_phone,
                       mobile_phone=mobile_phone,
                       work_phone=work_phone,
                       phone2=phone2)

    def new_contactWithID(self, contact, lastname, firstname, address, email,
                          email2, email3, home_phone, mobile_phone, work_phone,
                          phone2):
        return Contact(id=contact.id,
                       lastname=lastname,
                       firstname=firstname,
                       address=address,
                       email=email,
                       email2=email2,
                       email3=email3,
                       home_phone=home_phone,
                       mobile_phone=mobile_phone,
                       work_phone=work_phone,
                       phone2=phone2)

    def create_contact(self, new_contact):
        self.fixture.contact.add_new(new_contact)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def modify_contact(self, contact):
        self.fixture.contact.change_contact_by_id(contact.id, contact)