Skip to content
10 changes: 8 additions & 2 deletions mta/entities/projects.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from sys import platform

import attr
from taretto.navigate import NavigateToAttribute
from taretto.navigate import NavigateToSibling
Expand Down Expand Up @@ -87,6 +89,7 @@ class configure_analysis(View): # noqa
locator=".//wu-select-packages/h3[normalize-space(.)='Application packages']"
)
save_and_run = Button("Save & Run")
yes_button = Button("Yes")
fill_strategy = WaitFillViewStrategy("15s")

@property
Expand Down Expand Up @@ -165,13 +168,16 @@ def fill(self, values):
"""
if values.get("transformation_path"):
self.transformation_path.select_card(card_name=values.get("transformation_path"))
wait_for(lambda: self.application_packages.is_displayed, delay=0.6, timeout=240)
if not platform == "win32":
wait_for(lambda: self.application_packages.is_displayed, delay=0.6, timeout=500)
was_change = True
self.after_fill(was_change)
return was_change

def after_fill(self, was_change):
self.save_and_run.click()
if self.yes_button.is_displayed:
self.yes_button.click()

@property
def is_displayed(self):
Expand Down Expand Up @@ -302,7 +308,7 @@ def create(self, name, description=None, app_list=None, transformation_path=None
view = self.create_view(AnalysisResultsView)
view.wait_displayed("60s")
assert view.is_displayed
wait_for(lambda: view.analysis_results.in_progress(), delay=0.2, timeout=450)
wait_for(lambda: view.analysis_results.in_progress(), delay=20, timeout=450)
wait_for(lambda: view.analysis_results.is_analysis_complete(), delay=0.2, timeout=450)
assert view.analysis_results.is_analysis_complete()
return project
Expand Down
19 changes: 3 additions & 16 deletions mta/tests/test_analysis_results_Test03.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
import fauxfactory

from mta.entities.analysis_results import AnalysisResults
from mta.entities.analysis_results import AnalysisResultsView


def test_analysis_results_search_sort_delete(application):
def test_analysis_results_search_sort_delete(application, create_project):
""" Validates Web console Test 03
1) Upload more than one application into a project to analyse
2) Search analysis
3) Delete analysis
"""
project_name = fauxfactory.gen_alphanumeric(12, start="project_")
project_collection = application.collections.projects
project = project_collection.create(
name=project_name,
description=fauxfactory.gen_alphanumeric(),
app_list=[
"acmeair-webapp-1.0-SNAPSHOT.war",
"arit-ear-0.8.1-SNAPSHOT.ear",
"cadmium-war-0.1.0.war",
],
transformation_path="Containerization",
)
project, project_collection = create_project
assert project.exists

analysis_results = AnalysisResults(application, project_name)
analysis_results = AnalysisResults(application, project.name)
analysis_results.run_analysis()
view = analysis_results.create_view(AnalysisResultsView)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,22 @@ def test_advanced_options(application):
fs1 = FTPClientWrapper(env.ftpserver.entities.mta)
file_path = fs1.download("custom.Test1rules.rhamt.xml")
view.configure_analysis.use_custom_rules.upload_file.fill(file_path)
view.configure_analysis.use_custom_rules.add_rules_button.wait_displayed()
wait_for(
lambda: view.configure_analysis.use_custom_rules.add_rules_button.is_enabled,
delay=0.2,
timeout=60,
)
view.configure_analysis.use_custom_rules.add_rules_button.click()
wait_for(
lambda: view.configure_analysis.use_custom_rules.select_all_rules.is_enabled,
delay=0.2,
timeout=60,
)
view.configure_analysis.use_custom_rules.select_all_rules.click()

if view.configure_analysis.use_custom_rules.add_rules_button.is_enabled:
view.configure_analysis.use_custom_rules.add_rules_button.click()
else:
wait_for(
lambda: view.configure_analysis.use_custom_rules.add_rules_button.is_enabled,
delay=0.2,
timeout=60,
)
view.configure_analysis.use_custom_rules.add_rules_button.click()

if view.configure_analysis.use_custom_rules.select_all_rules.is_displayed:
view.configure_analysis.use_custom_rules.select_all_rules.click()
else:
view.configure_analysis.use_custom_rules.select_all_rules.wait_displayed("30s")
view.configure_analysis.use_custom_rules.select_all_rules.click()
assert view.configure_analysis.use_custom_rules.rule.is_displayed
view.configure_analysis.use_custom_rules.expand_custom_rules.click()

Expand All @@ -88,14 +91,22 @@ def test_advanced_options(application):
fs2 = FTPClientWrapper(env.ftpserver.entities.mta)
file_path = fs2.download("customWebLogic.windup.label.xml")
view.configure_analysis.use_custom_labels.upload_file.fill(file_path)
view.configure_analysis.use_custom_labels.add_labels_button.wait_displayed()
wait_for(
lambda: view.configure_analysis.use_custom_labels.add_labels_button.is_enabled,
delay=0.2,
timeout=60,
)
view.configure_analysis.use_custom_labels.add_labels_button.click()
view.configure_analysis.use_custom_labels.select_all_labels.click()

if view.configure_analysis.use_custom_labels.add_labels_button.is_enabled:
view.configure_analysis.use_custom_labels.add_labels_button.click()
else:
wait_for(
lambda: view.configure_analysis.use_custom_labels.add_labels_button.is_enabled,
delay=0.2,
timeout=60,
)
view.configure_analysis.use_custom_labels.add_labels_button.click()

if view.configure_analysis.use_custom_labels.select_all_labels.is_displayed:
view.configure_analysis.use_custom_labels.select_all_labels.click()
else:
view.configure_analysis.use_custom_labels.select_all_labels.wait_displayed("30s")
view.configure_analysis.use_custom_labels.select_all_labels.click()
assert view.configure_analysis.use_custom_labels.label.is_displayed
view.configure_analysis.use_custom_labels.expand_custom_labels.click()

Expand Down
17 changes: 12 additions & 5 deletions mta/widgetastic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,29 @@ def select_project(self, name):
class AnalysisResults(Widget):
# When there are multiple analysis the first row is latest one
# so we need to check spinner and success in 1st row
SPINNER_LOCATOR = (
'.//tr[contains(@class, "info")]/td[2]/wu-status-icon'
'/span[contains(@class, "status-icon")]/span[contains(@class,"spinner")]'
)
SPINNER_LOCATOR = ".//div[contains(@class ,'spinner spinner-xs')]"
ANALYSIS_STATUS = ".//tr[@class ='info']//td[2]"
COMPLETE_STATUS_LOCATOR = (
'.//tr[1]/td[2]//wu-status-icon/span/span[contains(@class, "fa fa-check")]'
)
SHOW_REPORT = './/i[contains(@class,"fa fa-bar-chart")]'

def in_progress(self):
return self.browser.is_displayed(self.SPINNER_LOCATOR)
if "In Progress" in self.get_status() or self.browser.is_displayed(self.SPINNER_LOCATOR):
return True
if "Queued" in self.get_status():
self.browser.refresh()
return False
return False

def is_analysis_complete(self):
"""Returns True if analysis complete and spinner not present"""
return self.browser.is_displayed(self.COMPLETE_STATUS_LOCATOR)

def get_status(self):
"""Returns text of status"""
return self.browser.text(self.ANALYSIS_STATUS)

def show_report(self):
self.browser.click(self.SHOW_REPORT)
self.switch_to_report()
Expand Down