def create_faq(): title = "title_FAQ" + Helper.rand_string("randomString") description = "description_FAQ_" + Helper.rand_string("randomString") DBCMS.delete_old_tips_of_the_day() postId = DBCMS.insert_cms_new_post(title, description, "FAQ") assertTrue(len(postId) > 0 and not None) return title, description
def add_vf(): try: logger.debug("Tab Add Virtual Functions") Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, Constants.Dashboard.Wizard.AddVF.Title.TEXT, wait_for_page=True) vfName = "newVF" + Helper.rand_string("randomString") vfVersion = "newVFVersion" + \ Helper.rand_string( "randomNumber") + Helper.rand_string("randomString") Enter.text_by_name("virtualFunction", vfName) Enter.text_by_name("VFversion", vfVersion, wait_for_page=True) FEWizard.date_picker_wizard() Select(session.ice_driver.find_element_by_id( Constants.Dashboard.Wizard.AddVF.AIC_Version.TEXT )).select_by_visible_text("AIC 3.5") Select(session.ice_driver.find_element_by_id( Constants.Dashboard.Wizard.AddVF.ECOMP_Release.TEXT )).select_by_visible_text("Unknown") session.E2Edate = FEWizard.get_lab_entry_date() Click.css(Constants.SubmitButton.CSS, wait_for_page=True) Wait.page_has_loaded() Wait.name_to_dissappear("Add Virtual Function") return vfName # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "Failed to add a Virtual Function via modal window. " +\ "Exception " +\ str(e) raise Exception(errorMsg)
def test_signup_page_sanity(self): ''' Purpose: Sanity test for sign-up page. Steps: - Go to sign-up page - Verify all approved vendors are listed - Verify all form fields exist. - Submit form without reCAPTCHA and verify error message. - Click on "Already have an account" and verify link. ''' Frontend.General.go_to_signup_from_login() vendors_list = DB.General.get_vendors_list() for vendor in vendors_list: Frontend.General.select_vendor_from_list(vendor) Frontend.General.form_enter_name(Helper.rand_string("randomString")) Frontend.General.form_enter_email(Helper.rand_string("email")) Frontend.General.form_enter_phone(Constants.Default.Phone.TEXT) Frontend.General.form_enter_password( Helper.rand_string("randomString")) Frontend.General.form_check_checkbox( Constants.Signup.RegularEmail.XPATH) Frontend.General.form_check_checkbox( Constants.Signup.AcceptTerms.XPATH) Frontend.General.click_on_submit() Frontend.General.verify_toast_message( Constants.Signup.Toast.Captcha.TEXT) Frontend.General.go_to_login_from_signup()
def create_page(parent_id=None): title = "title_Of_Page_" + Helper.rand_string("randomString") description = "description_Of_Page_" + \ Helper.rand_string("randomString") createdPageId = DBCMS.insert_page(title, description) assertTrue(len(createdPageId) > 0 and not None) return title, description
def test_validate_bucket_removed(self): bucket, user_content = self.create_bucket_and_validate_users() # set Completed Stage API.VirtualFunction.set_eng_stage(user_content, Constants.EngagementStages.COMPLETED) # validate users removed from bucket bucket_id = user_content['engagement_manual_id'] + "_" + user_content[ 'vfName'].lower() assertTrue( API.Rados.users_of_bucket_ready_after_complete( bucket_id, user_content['full_name'])) assertTrue(API.Rados.is_bucket_ready(bucket_id)) assertTrue(bucket != "None") # try create upload file - must failed str_content = Helper.rand_string("randomString") + Helper.rand_string( "randomNumber") fileName = Helper.rand_string("randomString") bucket = API.Rados.get_bucket(bucket_id) assertTrue(API.Rados.is_bucket_ready(bucket_id)) key = bucket.new_key(fileName + '.dat') key.set_contents_from_string(str_content) pprint(key.generate_url(expires_in=400)) # DOWNLOAD AN OBJECT (TO A FILE) key = bucket.get_key(fileName + '.dat') key.get_contents_to_filename('/home/' + fileName + '.dat') key.delete()
def create_announcement(): title = "title_Announcement_" + Helper.rand_string("randomString") description = "description_Announcement_" + \ Helper.rand_string("randomString") postId = DBCMS.insert_cms_new_post(title, description, "Announcement") assertTrue(len(postId) > 0 and not None) return title, description
def signup_invited_user( company, invited_email, invite_token, invite_url, user_content, is_contact_user="******", activate=False, wait_for_gitlab=True): r1 = None postURL = settings.ICE_EM_URL + '/v1/engmgr/signup' logger.debug("Post signup URL: " + postURL) if is_contact_user == "true": fullName = re.sub("http.*full_name=", "", invite_url) fullName = re.sub("&.*", "", fullName) logger.debug( "Invited contact full name is (according to url): " + fullName) else: fullName = Helper.rand_string('randomString') post_data = dict() # Create JSON data for post request. post_data['company'] = company post_data['email'] = invited_email post_data['full_name'] = fullName post_data['invitation'] = invite_token post_data['is_contact_user'] = is_contact_user post_data['password'] = "******" post_data['phone_number'] = "+1201" + \ Helper.rand_string("randomNumber", 6) post_data['regular_email_updates'] = "False" post_data['terms'] = "True" try: requests.get(invite_url, verify=False) r1 = requests.post( postURL, json=post_data, verify=False) Helper.internal_assert(r1.status_code, 200) logger.debug("Invited user signed-up successfully!") user_data = r1.json() if activate: APIUser.activate_user( user_data['uuid'], user_data["user"]["activation_token"]) if wait_for_gitlab: if not APIBridge.is_gitlab_ready(user_content): raise return post_data except BaseException: if r1 is None: logger.error("Failed to sign up the invited team member.") else: logger.error( "POST request failed to sign up the invited " + "team member, see response >>> %s %s \n %s" % (r1.status_code, r1.reason, str( r1.content, 'utf-8'))) raise
def test_search_bar(self): """ Create user and VF, log in, add VFC, search by EID, VF and VFC """ vfFullName = self.user_content[ 'engagement_manual_id'] + ": " + self.user_content['vfName'] try: Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, self.user_content['vfName']) Wait.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Wait.text_by_id( Constants.Dashboard.Overview.Title.ID, vfFullName) except BaseException: errorMsg = "Failed to search by VF name." raise Exception(errorMsg) try: Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, self.user_content['engagement_manual_id']) Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, self.user_content['engagement_manual_id']) Wait.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS) Wait.text_by_id( Constants.Dashboard.Overview.Title.ID, vfFullName) except BaseException: errorMsg = "Failed to search by Engagement Manual ID." raise Exception(errorMsg) Frontend.Overview.click_on_vf(self.user_content) detailedViewID = Constants.Dashboard.DetailedView.ID + vfFullName Wait.text_by_id(detailedViewID, "Detailed View", wait_for_page=True) Click.id(detailedViewID, wait_for_page=True) Click.id( Constants.Dashboard.DetailedView.VFC.Add.ID, wait_for_page=True) vfcName = Helper.rand_string("randomString") extRefID = Helper.rand_string("randomNumber") Enter.text_by_name("name", vfcName) Enter.text_by_name("extRefID", extRefID, wait_for_page=True) Select(session.ice_driver.find_element_by_id( Constants.Dashboard.DetailedView.VFC.Choose_Company.ID)).\ select_by_visible_text(self.user_content['vendor']) Click.id( Constants.Dashboard.DetailedView.VFC.Save_button.ID, wait_for_page=True) try: Enter.text_by_id( Constants.Dashboard.LeftPanel.SearchBox.ID, vfcName, wait_for_page=True) Click.id( "search-" + self.user_content['vfName'], wait_for_page=True) Wait.id("clickable-" + vfFullName, wait_for_page=True) except Exception as e: errorMsg = "Failed to search by VFC name." raise Exception(errorMsg + str(e))
def add_vfc(): vfcName = "VFC-" + Helper.rand_string("randomString") Click.id(Constants.Dashboard.DetailedView.VFC.Add.ID) Enter.text_by_name("name", vfcName) session.ice_driver.find_element_by_name("extRefID").click() Enter.text_by_name("extRefID", Helper.rand_string("randomNumber")) Select( session.ice_driver.find_element_by_id( Constants.Dashboard.DetailedView.VFC.Choose_Company.ID) ).select_by_visible_text(ServiceProvider.MainServiceProvider) Click.id(Constants.Dashboard.DetailedView.VFC.Save_button.ID) return vfcName
def create_announcements(x): listOfTitleAnDescriptions = [] for _ in range(x): # print x ->str title = "title_Announcement_" + Helper.rand_string("randomString") description = "description_Announcement_" + \ Helper.rand_string("randomString") postId = DBCMS.insert_cms_new_post(title, description, "Announcement") assertTrue(len(postId) > 0 and not None) xList = [title, description] listOfTitleAnDescriptions.append(xList) return listOfTitleAnDescriptions
def edit_description_lineitem_and_save(): desc = Helper.rand_string("randomString") Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_LINE_ITEM_ID) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN) Enter.text_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_NAME, Helper.rand_string("randomString")) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_DESC) editor_element = Get.wysiwyg_element_by_id( Constants.Dashboard.LeftPanel.EditChecklistTemplate. LINE_ITEM_DESC_TEXT_BOX) editor_element.clear() editor_element.send_keys(desc) Wait.page_has_loaded() actionChains = ActionChains(session.ice_driver) actionChains.double_click(editor_element).perform() Wait.page_has_loaded() Click.xpath(Constants.Dashboard.LeftPanel.EditChecklistTemplate. WYSIWYG_BUTTON_BOLD) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN, wait_for_page=True) isBold = Wait.is_css_exists("b") while not isBold: Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN, wait_for_page=True) actionChains.double_click(editor_element).perform() Click.xpath(Constants.Dashboard.LeftPanel.EditChecklistTemplate. WYSIWYG_BUTTON_BOLD, wait_for_page=True) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. EDIT_LINE_ITEM_BTN, wait_for_page=True) isBold = Wait.is_css_exists("b") if isBold: FEChecklistTemplate.click_on_save_and_assert_success_msg() FEGeneral.refresh() Click.name(Constants.Dashboard.LeftPanel.EditChecklistTemplate.HEAT, wait_for_page=True) Click.id(Constants.Dashboard.LeftPanel.EditChecklistTemplate. FIRST_LINE_ITEM_ID, wait_for_page=True) Wait.css("b") Wait.text_by_css("b", desc, wait_for_page=True)
def edit_next_step(user_content, ns_uuid): r1 = None postURL = settings.ICE_EM_URL + '/v1/engmgr/nextsteps/' + ns_uuid + \ '/engagement/' + user_content['engagement_uuid'] + '/modify/' logger.debug("Put next step URL: " + postURL) headers = dict() # Create header for post request. headers['Content-type'] = 'application/json' headers['Authorization'] = user_content['session_token'] data = dict() # Create JSON data for post request. data['files'] = [] data['assigneesUuids'] = [user_content['uuid']] data['duedate'] = str(datetime.date.today()) data['description'] = "API edit next step test " + \ Helper.rand_string('randomString') try: r1 = requests.put(postURL, json=data, headers=headers, verify=False) Helper.internal_assert_boolean(r1.status_code, 202) logger.debug("Next step was edited successfully!") except BaseException: if r1 is None: logger.error("Failed to edit next step uuid: " + ns_uuid) else: logger.error("Failed to edit next step uuid: " + ns_uuid + ", see response >>> %s %s" % (r1.status_code, r1.reason)) raise
def invite_team_member(user_content): r1 = None postURL = settings.ICE_EM_URL + '/v1/engmgr/invite-team-members/' logger.debug("Post invite user URL: " + postURL) headers = dict() # Create header for post request. headers['Content-type'] = 'application/json' headers['Authorization'] = user_content['session_token'] data = dict() # Create JSON data for post request. data['email'] = Helper.rand_string( 'randomString') + "@" + ServiceProvider.email data['eng_uuid'] = user_content['engagement_uuid'] list_data = [] list_data.append(data) try: r1 = requests.post(postURL, json=list_data, headers=headers, verify=False) Helper.internal_assert_boolean(r1.status_code, 200) logger.debug("Invite sent successfully to email " + data['email']) invite_token = DBGeneral.select_where_and( "invitation_token", "ice_invitation", "email", data['email'], "engagement_uuid", user_content['engagement_uuid'], 1) invite_url = settings.ICE_PORTAL_URL + "/#/signUp?invitation=" + \ invite_token + "&email=" + data['email'] logger.debug("Invitation URL is: " + invite_url) return data['email'], invite_token, invite_url except BaseException: if r1 is None: logger.error("Failed to invite team member.") else: logger.error("POST request failed to invite team member, " + "see response >>> %s %s" % (r1.status_code, r1.reason)) raise
def search_in_dashboard(user_content, vfcName, users): engName = user_content['engagement_manual_id'] + ": " + user_content[ 'vfName'] engSearchID = "eng-" + engName for user in users: FEGeneral.re_open(Constants.Default.LoginURL.TEXT) logger.debug("Login with user " + user) FEUser.login(user, Constants.Default.Password.TEXT) logger.debug("Search engagement by engagement_manual_id") Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, user_content['engagement_manual_id']) eng_manual_id = user_content['engagement_manual_id'] + ":" Wait.text_by_id(engSearchID, eng_manual_id) logger.debug("Engagement found (searched by engagement_manual_id)") FEGeneral.smart_refresh() logger.debug("Search engagement by VF name") # Search by VF name. Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, user_content['vfName']) Wait.text_by_id(engSearchID, eng_manual_id) logger.debug("Engagement found (searched by VF name)") FEGeneral.smart_refresh() logger.debug("Search engagement by VFC") # Search by VFC. Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, vfcName) Wait.text_by_id(engSearchID, eng_manual_id) logger.debug("Engagement found (searched by VFC)") FEGeneral.smart_refresh() logger.debug("Negative search: search by random string") # Search by VFC. Enter.text_by_id(Constants.Dashboard.Statuses.SearchBox.ID, "RND_STR_" + Helper.rand_string("randomString")) Wait.text_by_id("search-results", "Export to Excel >>")
def test_ecomp_dropdown_ordering(self): new_ecomp_release = None try: new_ecomp_release = { "uuid": uuid.uuid4(), "name": Helper.rand_string() } DB.VirtualFunction.change_ecomp_release_weight(10, 0) DB.VirtualFunction.insert_ecomp_release(new_ecomp_release['uuid'], new_ecomp_release['name']) Frontend.User.login(self.user_content['el_email'], Constants.Default.Password.TEXT) Frontend.DetailedView.search_vf_and_go_to_detailed_view( self.user_content['engagement_manual_id'], self.user_content['vfName']) Frontend.DetailedView.click_on_update_ecomp_release() Helper.internal_assert( Frontend.General.get_meta_order_of_element( Constants.Dashboard.DetailedView.ECOMP.Dropdown. UniversalRelease.ID % new_ecomp_release['name']), 0) finally: if new_ecomp_release: DB.VirtualFunction.delete_ecomp_release( new_ecomp_release['uuid'], new_ecomp_release['name']) DB.VirtualFunction.change_ecomp_release_weight(0, 10)
def test_retire_ecomp_release(self): new_ecomp_release = None try: new_ecomp_release = { "uuid": uuid.uuid4(), "name": Helper.rand_string(), "ui_visibility": "FALSE" } DB.VirtualFunction.insert_ecomp_release( new_ecomp_release['uuid'], new_ecomp_release['name'], new_ecomp_release['ui_visibility']) Frontend.User.login(self.user_content['el_email'], Constants.Default.Password.TEXT) Frontend.DetailedView.search_vf_and_go_to_detailed_view( self.user_content['engagement_manual_id'], self.user_content['vfName']) Frontend.DetailedView.click_on_update_ecomp_release() session.run_negative( lambda: Frontend.General.get_meta_order_of_element( Constants.Dashboard.DetailedView.ECOMP.Dropdown. UniversalRelease.ID % new_ecomp_release['name']), "New ECOMP release was found in dropdown.") finally: if new_ecomp_release: DB.VirtualFunction.delete_ecomp_release( new_ecomp_release['uuid'], new_ecomp_release['name'])
def test_login_negative(self): ''' Negative: Type wrong password in login page. ''' user_content = API.User.create_new_user(activate=True) Frontend.User.login(user_content['email'], Helper.rand_string("randomString"), Constants.Toast.ID) Wait.text_by_id(Constants.Toast.ID, Constants.Login.Toast.TEXT) logger.debug( "Message Error(APIUser or Password does not match) Displayed")
def test_validate_bucket_created(self): bucket, user_content = self.create_bucket_and_validate_users() # create upload file str_content = Helper.rand_string("randomString") + Helper.rand_string( "randomNumber") fileName = Helper.rand_string("randomString") bucket_id = user_content['engagement_manual_id'] + "_" + user_content[ 'vfName'].lower() Wait.bucket_to_create(bucket_id) bucket = API.Rados.get_bucket(bucket_id) assertTrue(API.Rados.is_bucket_ready(bucket_id)) key = bucket.new_key(fileName + '.dat') key.set_contents_from_string(str_content) pprint(key.generate_url(expires_in=400)) # DOWNLOAD AN OBJECT (TO A FILE) key = bucket.get_key(fileName + '.dat') key.get_contents_to_filename('/home/' + fileName + '.dat') key.delete()
def add_feedback(): Wait.css("textarea[name=\"description\"]", wait_for_page=True) description = Helper.rand_string("randomString") Enter.text_by_css("textarea[name=\"description\"]", description) Click.id(Constants.Dashboard.Feedback.FeedbackModal.SAVE_BTN_ID, wait_for_page=True) Wait.text_by_id(Constants.Toast.ID, "Feedback was sent successfully.", wait_for_page=True) return description
def add_vendor_contact(): logger.debug("Tab Add Vendor Contact") Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, Constants.Dashboard.Wizard.AddVendorContact.Title.TEXT, wait_for_page=True) Select(session.ice_driver.find_element_by_name( "company")).select_by_visible_text("Ericsson") fullname = Helper.rand_string( "randomString") + Helper.rand_string("randomString") Enter.text_by_name("fullname", fullname) email = Helper.rand_string("randomString") + "@ericson.com" Enter.text_by_name("email", email) phone = "201" + Helper.rand_string("randomNumber", 6) Enter.text_by_name("phone", phone) Click.css(Constants.SubmitButton.CSS, wait_for_page=True) Wait.name_to_dissappear("Add Vendor Contact", wait_for_page=True) vendor = {"company": "Ericsson", "full_name": fullname, "email": email, "phone": phone} return vendor
def create_vf(token): r1 = None postUrl = settings.EM_REST_URL + "vf/" targetVersion = DBGeneral.select_from("uuid", "ice_deployment_target", 1) ecompRelease = DBGeneral.select_from("uuid", "ice_ecomp_release", 1) headers = dict() # Create header for post request. headers['Content-type'] = 'application/json' headers['Authorization'] = 'token ' + token jdata = [{ "virtual_function": Helper.rand_string("randomString"), "version": Helper.rand_string("randomString") + Helper.rand_string("randomNumber"), "target_lab_entry_date": time.strftime("%Y-%m-%d"), "target_aic_uuid": targetVersion, "ecomp_release": ecompRelease, "is_service_provider_internal": False }] try: r1 = requests.post(postUrl, json=jdata, headers=headers, verify=False) Helper.internal_assert(r1.status_code, 200) logger.debug("Virtual Function created successfully!") content = r1.content[1:-1] return content except BaseException: if r1 is None: logger.debug("Failed to create VF >>> request failed!") else: logger.debug( "Failed to create VF >>> %s %s \n %s" % (r1.status_code, r1.reason, str(r1.content, 'utf-8'))) raise
def create_signup_param(company=False): try: # Click on element in UI, by xPath locator. if not company: company = ServiceProvider.MainServiceProvider email_domain = ServiceProvider.email else: email_domain = company.lower() + ".com" # data = { "company": company, "full_name": Helper.rand_string("randomString"), "email": Helper.rand_string("randomString") + "@" + email_domain, "phone_number": Constants.Default.Phone.TEXT, "password": Constants.Default.Password.TEXT, "regular_email_updates": "True"} return data # If failed - count the failure and add the error to list of errors. except Exception as e: errorMsg = "Could not create Sign Up parametrs" raise Exception(errorMsg, e)
def add_contact(user_content): r1 = None postURL = settings.ICE_EM_URL + '/v1/engmgr/add-contact/' logger.debug("Post invite vendor contact URL: " + postURL) headers = dict() # Create header for post request. headers['Content-type'] = 'application/json' headers['Authorization'] = user_content['session_token'] data = dict() # Create JSON data for post request. data['company'] = user_content['vendor_uuid'] data['email'] = Helper.rand_string( 'randomString') + "@" + ServiceProvider.email data['eng_uuid'] = user_content['engagement_uuid'] data['full_name'] = Helper.rand_string('randomString') data['phone_number'] = "+1201" + Helper.rand_string("randomNumber", 6) try: r1 = requests.post(postURL, json=data, headers=headers, verify=False) Helper.internal_assert_boolean(r1.status_code, 200) logger.debug("Invite sent successfully to email " + data['email']) invite_token = DBGeneral.select_where_and( "invitation_token", "ice_invitation", "email", data['email'], "engagement_uuid", user_content['engagement_uuid'], 1) invite_url = settings.ICE_PORTAL_URL + "/#/signUp?invitation=" +\ invite_token + "&email=" + data['email'] +\ "&full_name=" + data['full_name'] + \ "&phone_number=" + data['phone_number'] + "&company=" + \ data['company'] + "&is_contact_user=true" logger.debug("Invitation URL is: " + invite_url) return data['email'], invite_token, invite_url except BaseException: if r1 is None: logger.error("Failed to invite vendor contact.") else: logger.error( "POST request failed to invite vendor contact, " + "see response >>> %s %s \n %s" % (r1.status_code, r1.reason, str(r1.content, 'utf-8'))) raise
def update_cl_name_and_associated_files(engagement_manual_id): Click.id("edit-checklist", True) Wait.text_by_id("modal-header-checklist-15", "Update Checklist") newfileName = "file" + Helper.rand_string("randomString") Enter.text_by_xpath("//div[3]/div/div/input", newfileName) updatedFileName = "file2" # Select associated files from multi-select drop-down. Click.xpath("//multiselect/div/button") Click.link_text("file2") Click.css(Constants.SubmitButton.CSS) Wait.id(engagement_manual_id) newFileNames = [newfileName, updatedFileName] return newFileNames
def test_validate_upload_download_image_with_bucket_user(self): bucket, user_content = self.create_bucket_and_validate_users() # connect to bucket with specific user bucket_id = user_content['engagement_manual_id'] + "_" + user_content[ 'vfName'].lower() access_key = DBUser.get_access_key(user_content['uuid']) secret_key = DBUser.get_access_secret(user_content['uuid']) secret = CryptographyText.decrypt(secret_key) bucket_for_specific_user = API.Rados.get_bucketfor_specific_user( bucket_id, access_key, secret) assertTrue(bucket_for_specific_user is not None) # create upload file with user str_content = Helper.rand_string("randomString") + Helper.rand_string( "randomNumber") fileName = Helper.rand_string("randomString") key = bucket_for_specific_user.new_key(fileName + '.dat') key.set_contents_from_string(str_content) pprint(key.generate_url(expires_in=3600)) # DOWNLOAD AN OBJECT (TO A FILE) key = bucket_for_specific_user.get_key(fileName + '.dat') key.get_contents_to_filename('/home/' + fileName + '.dat') key.delete()
def add_service_provider_internal(): logger.debug( "Tab Add " + ServiceProvider.MainServiceProvider + " Sponsor") Wait.text_by_css( Constants.Dashboard.Wizard.Title.CSS, "Add " + ServiceProvider.MainServiceProvider + " Sponsor") fullname = Helper.rand_string( "randomString") + Helper.rand_string("randomString") Enter.text_by_name("fullname", fullname) email = Helper.rand_string( "randomString") + "@" + ServiceProvider.email Enter.text_by_name("email", email) phone = "201" + Helper.rand_string("randomNumber", 6) logger.debug(phone) Enter.text_by_name("phone", phone) Click.css(Constants.SubmitButton.CSS) Wait.name_to_dissappear("Add AT&T Sponsor") sponsor = {"company": ServiceProvider.MainServiceProvider, "full_name": fullname, "email": email, "phone": phone} return sponsor
def add_line_item_audit_log(): try: log_txt = Helper.rand_string("randomString") Enter.text_by_id("new-audit-log-text", log_txt, wait_for_page=True) Click.id("submit-new-audit-lop-text") Wait.text_by_css( Constants.Dashboard.Checklist.AuditLog.LastLocalAuditLog.CSS, log_txt, wait_for_page=True) return log_txt except Exception as e: errorMsg = "Failed to add audit log to line item." raise Exception(errorMsg, e)
def test_edit_ecomp_release(self): try: EcompUuid = uuid.uuid4() EcompName = Helper.rand_string("randomString") DB.VirtualFunction.insert_ecomp_release(EcompUuid, EcompName) Frontend.User.login(self.user_content['email'], Constants.Default.Password.TEXT) Frontend.DetailedView.search_vf_and_go_to_detailed_view( self.user_content['engagement_manual_id'], self.user_content['vfName']) Frontend.DetailedView.update_ecomp_release(EcompName) Frontend.DetailedView.validate_ecomp_version() finally: DB.VirtualFunction.delete_ecomp_release(EcompUuid, EcompName)
def update_account_and_return_changes(): try: Select(session.ice_driver.find_element_by_name( "company")).select_by_visible_text("Nokia") randomName = Helper.rand_string("randomString") Enter.text_by_name("fullname", randomName) phone = "97258" + Helper.rand_string("randomNumber", 6) Enter.text_by_name("phone", phone) password = Constants.Default.Password.NewPass.TEXT Enter.text_by_name("password", password) Enter.text_by_name("confirm_password", password) Wait.text_by_css("button.btn.btn-primary", "Update") Click.css("button.btn.btn-primary") Wait.text_by_id(Constants.Toast.ID, "Account was updated successfully!") Click.id(Constants.Dashboard.Statuses.ID) accountObj = [randomName, phone, password] return accountObj # If failed - count the failure and add the error to list of errors. except BaseException: errorMsg = "Failed in update accaunt ." raise Exception(errorMsg) raise
def create_cl_without_files(user_content): FEOverview.click_on_vf(user_content) Click.id("checklist-plus-" + user_content['engagement_uuid']) Wait.id(Constants.Dashboard.Modal.CLOSE_BUTTON_ID) checklistName = "NoAssociatedFiles" + \ Helper.rand_string("randomString") Enter.text_by_name("checkListName", checklistName) Wait.xpath("//select") if settings.DATABASE_TYPE == 'local': Select(session.ice_driver.find_element_by_xpath( "//select")).select_by_visible_text( Constants.Template.Heat.TEXT) else: Click.xpath("//select") Click.xpath("//option[2]") Click.id(Constants.Dashboard.LeftPanel.CreateChecklist.ID) Wait.text_by_id(Constants.Dashboard.Checklist.Name.ID, checklistName)