def set_up_mock_timeout(): mock = HTTPMockTimeoutServer(host=settings.MOCK_HOST, port=settings.MOCK_PORT) mock.start() wait_until(run_app) yield mock.stop() shutdown_wait()
def test_mock_500(self, set_up_mock_500): client = SocketClient(port=settings.APP_PORT, host=settings.APP_HOST) wait_until(client.connect) data, headers = self.get_info(sort='Apple') response = client.request(method='POST', headers=headers, url='/setnew', data=data) assert response[-1] == 'Server internal error'
def test_clicking_title_loads_source_website(self, firefox): sidebar.updatescanner_website_item.click() page_view.updatescanner_title.click() wait_until( firefox.get_current_url, equals="https://sneakypete81.github.io/updatescanner/", timeout_seconds=30, )
def test_mock_timeout(self, set_up_mock_timeout): client = SocketClient(port=settings.APP_PORT, host=settings.APP_HOST) wait_until(client.connect) client.sock.settimeout(3.1) data, headers = self.get_info(sort='Apple') response = client.request(method='POST', headers=headers, url='/setnew', data=data) assert response[-1] == 'Server timed out'
def test_mock_unavailable(self, set_up_without_mock): client = SocketClient(port=settings.APP_PORT, host=settings.APP_HOST) wait_until(client.connect) data = {'sort': 'Apple'} data = json.dumps(data) headers = self.get_headers(len(data.encode())) response = client.request(method='POST', headers=headers, url='/setnew', data=data) assert response[-1] == 'Connection refused'
def k8s_tests(health_config, phase, runid): kubeconfig = health_config['k8s']['kubeconfig'] worker_public_address_list = health_config['k8s']['worker-address-list'] master_public_address_list = health_config['k8s']['master-address-list'] # Health check logger.info('Verifying health...') health.test_k8s(kubeconfig) verify_num_nodes(len(worker_public_address_list + master_public_address_list), kubeconfig=kubeconfig) # Before phase: deploy 2 services that talk to each other internally and are exposed externally if execute_before_phase(phase): logger.info("Deploying hello service") testhelpers.kubectl('apply -f %s/resources/hello-service.yml' % TESTS_DIR, kubeconfig=kubeconfig) hello_pods_ready = lambda: verify_num_pods( num=15, kubeconfig=kubeconfig, regex='^hello') helpers.wait_until(hello_pods_ready, 180) # This sleep shouldn't be necessary in latest versions of k8s time.sleep(5) testhelpers.kubectl('apply -f %s/resources/frontend-service.yml' % TESTS_DIR, kubeconfig=kubeconfig) frontend_pods_ready = lambda: verify_num_pods( num=3, kubeconfig=kubeconfig, regex='^frontend') helpers.wait_until(frontend_pods_ready, 180) hello_service_port = testhelpers.kubectl( 'get svc/hello -o jsonpath={.spec.ports[0].nodePort}', kubeconfig=kubeconfig) logger.info('Hello service port: %s' % str(hello_service_port)) frontend_service_port = testhelpers.kubectl( 'get svc/frontend -o jsonpath={.spec.ports[0].nodePort}', kubeconfig=kubeconfig) logger.info('Frontend service port: %s' % str(frontend_service_port)) # After phase: verify services are pingable if execute_after_phase(phase): try: logger.info( 'Pinging hello and frontend deployments for each K8s worker') for worker_public_address in worker_public_address_list: service_address_list = [ 'http://%s:%s' % (worker_public_address, hello_service_port), 'http://%s:%s' % (worker_public_address, frontend_service_port) ] for service_address in service_address_list: logger.info('Checking ' + service_address) deployment_ready = lambda: verify_status_code( service_address, 200) helpers.wait_until(deployment_ready, 180) finally: testhelpers.kubectl('delete -f %s/resources/hello-service.yml' % TESTS_DIR, kubeconfig=kubeconfig, exit_on_error=False) testhelpers.kubectl('delete -f %s/resources/frontend-service.yml' % TESTS_DIR, kubeconfig=kubeconfig, exit_on_error=False)
def main(): profile = webdriver.FirefoxProfile("Z:/05 Profiles/SeleniumFF") driver = webdriver.Firefox(profile) driver.get(constants.APPROWEB_URL) # Login wait_until('#LoginForm_ip', 'present', driver) field_username = driver.find_element_by_id('LoginForm_ip') field_password = driver.find_element_by_id('LoginForm_kataSandi') field_username.send_keys(constants.APPROWEB_USER) field_password.send_keys(constants.APPROWEB_PASSWORD) field_password.send_keys(Keys.RETURN) wait_until('#notifPopup button', 'clickable', driver) driver.find_element_by_css_selector('#notifPopup button').click() driver.get(constants.APPROWEB_URL + 'index.php?r=crmAwas2019/petarisiko19') # WebDriverWait(driver, 60).until(EC.element_to_be_clickable(( # By.CSS_SELECTOR, '#s2id_CrmAwasModel19_wilayah > a.select2-choice'))) wait_until('#s2id_CrmAwasModel19_wilayah > a.select2-choice', 'clickable', driver) driver.find_element_by_css_selector( '#s2id_CrmAwasModel19_wilayah > a.select2-choice').click() dropdown_wilayah = driver.find_element_by_css_selector( "#select2-drop:not([style*='display: none'])") dropdown_wilayah.find_element_by_xpath( "//div[contains(text(), 'BANDA ACEH')]").click() driver.find_element_by_css_selector('#yw0 input[type="submit"]').click() sleep(3) # WebDriverWait(driver, 60).until(EC.element_to_be_clickable(( # By.CSS_SELECTOR, '.portlet-title .actions > a'))) wait_until('.portlet-title .actions > a', 'clickable', driver) driver.find_element_by_css_selector('.portlet-title .actions > a').click() # wait until #employee-grid_processing display:none # WebDriverWait(driver, 60).until( # EC.invisibility_of_element_located((By.ID, 'employee-grid_processing'))) wait_until('#employee-grid_processing', 'invisible', driver) driver.find_element_by_css_selector( '#employee-grid_filter label input').send_keys('025618133101000') driver.find_element_by_id('tombolCari').click() # WebDriverWait(driver, 60).until( # EC.invisibility_of_element_located((By.ID, 'employee-grid_processing'))) wait_until('#employee-grid_processing', 'invisible', driver) driver.find_element_by_css_selector( '#employee-grid tbody tr:first-child td:nth-child(3) a').click() # WebDriverWait(driver, 60).until( # EC.presence_of_element_located((By.ID, 'profilRisiko'))) wait_until('#profilRisiko', 'present', driver) petaRisiko = driver.find_element_by_id("profilRisiko") # for row in petaRisiko.find_elements_by_css_selector('tr'): # for cell in row.find_elements_by_css_selector('td'): # print(cell.text) # with open('peta_risiko.csv', 'w', newline='') as csvfile: # wr = csv.writer(csvfile) # for row in petaRisiko.find_elements_by_css_selector('tr'): # for cell in row.find_elements_by_css_selector('td'): # print(cell.text) # wr.writerow(cell.text) driver.get( petaRisiko.find_elements_by_css_selector('tbody a')[2].get_attribute( 'href')) outputTable = driver.find_elements_by_css_selector('#output table')[-1] with open('outputRisiko.csv', 'w', newline='') as csvfile: wr = csv.writer(csvfile, delimiter=';', quoting=csv.QUOTE_MINIMAL) for row in outputTable.find_elements_by_css_selector('tr'): currentRow = [] for cell in row.find_elements_by_css_selector('th > div'): currentRow.append(cell.get_attribute('innerHTML')) for cell in row.find_elements_by_css_selector('td'): currentRow.append(cell.text) print(currentRow) wr.writerow(currentRow)
def set_up(run): client = SocketClient(port=settings.APP_PORT, host=settings.APP_HOST) wait_until(client.connect) return client