def add_del_valid_user(self): """Fixture to add valid user to DB, test and delete user""" user_data = { 'u': gen_rand_name(), 'p': gen_rand_pass(), 'e': gen_rand_email() } self.add_user_for_test(user_data['u'], user_data['p'], user_data['e']) yield user_data self.builder.del_user_by_name(user_data['u'])
def test_invalid_reg_diff_pass(self, registration_page): """ Check registration with different passwords """ username = gen_rand_name() registration_page.registration(username, gen_rand_email(), gen_rand_pass(), gen_rand_pass(), True) check = registration_page.reg_is_complete() self.builder.del_user_by_name(username) assert check is None and check is None, \ 'Can registrate with different passwords'
def test_valid_reg(self, registration_page, add_del_valid_user): """ Check registration with valid data """ username = gen_rand_name() password = gen_rand_pass() registration_page.registration(username, gen_rand_email(), password, password, True) check = registration_page.reg_is_complete() self.builder.del_user_by_name(username) assert check is not None, 'Cant registrate with valid data'
def test_invalid_reg_bad_email_4(self, registration_page): """ Check registration with the same email """ USER1 = gen_rand_name() USER2 = gen_rand_name() PASSWORD = gen_rand_pass() EMAIL = gen_rand_email() self.builder.del_user_by_name(USER1) self.builder.del_user_by_email(USER2) self.builder.del_user_by_email(EMAIL) registration_page.registration(USER1, EMAIL, PASSWORD, PASSWORD, True) registration_page.go_reg_again() registration_page.registration(USER2, EMAIL, PASSWORD, PASSWORD, True) check = registration_page.reg_is_complete() self.builder.del_user_by_name(USER1) self.builder.del_user_by_name(USER2) assert check is None, 'Can registrate with the same email'
def test_invalid_reg_no_accept(self, registration_page): """ Check registration without accept that I want to be a SDET """ username = gen_rand_name() password = gen_rand_pass() registration_page.registration(username, gen_rand_email(), password, password, False) check = registration_page.reg_is_complete() self.builder.del_user_by_name(username) assert check is None and check is None, \ 'Can registrate without accept terms'
def test_vk_id(self, registration_page): """ Check active in DB after redirect after reg. """ username = gen_rand_name() password = gen_rand_pass() add_user_vk_id(100, username) registration_page.registration(username, gen_rand_email(), password, password, True) check = registration_page.find_vk_id() self.builder.del_user_by_name(username) assert check is not None, \ 'Not active, but not passive'
def test_active_after_reg(self, registration_page): """ Check active in DB after redirect after reg. """ username = gen_rand_name() password = gen_rand_pass() registration_page.registration(username, gen_rand_email(), password, password, True) check = registration_page.reg_is_complete() res_active = self.mysql.session.query(TestUsers).filter( TestUsers.username == username).first().active self.builder.del_user_by_name(username) assert check is not None and res_active == 1, \ 'Not active, but not passive'
def check_different_email_to_registrate(self, registration_page, email): username = gen_rand_name() password = gen_rand_pass() self.registrate_user(registration_page, username=username, password=password, email=email) try: check = registration_page.reg_is_complete() res = self.mysql.session.query(TestUsers).filter( TestUsers.username == username).first() finally: self.builder.del_user_by_name(username) self.builder.del_user_by_email(email) return check and res
def test_invalid_reg_bad_username_4(self, registration_page): """ Check registration with same username """ USER = gen_rand_name() PASSWORD = gen_rand_pass() EMAIL1 = gen_rand_email() EMAIL2 = gen_rand_email() self.builder.del_user_by_email(EMAIL1) self.builder.del_user_by_email(EMAIL2) registration_page.registration(USER, EMAIL1, PASSWORD, PASSWORD, True) registration_page.go_reg_again() registration_page.registration(USER, EMAIL2, PASSWORD, PASSWORD, True) check = registration_page.reg_is_complete() self.builder.del_user_by_name(USER) assert check is None, 'Can registrate with the same username'