Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
haraprasadj committed Jun 7, 2024
1 parent 6aeb9ff commit 41e44b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
21 changes: 10 additions & 11 deletions gen3-integration-tests/pages/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ def __init__(self):
self.WORKSPACE_OPTIONS = (
"//div[@class='workspace__options']" # Workspace Options
)
self.WORKSPACE_SPINNER = (
"//div[@class='workspace__spinner-container']" # workspace loading spinner
)
self.WORKSPACE_IFRAME = 'iframe[title="Workspace"]' # Workspace iframe
# Locators inside the workspace iframe
self.NEW_NB = (
Expand Down Expand Up @@ -76,9 +73,10 @@ def launch_workspace(self, page: Page, name: str = ""):
launch_button = page.locator(launch_button_xpath)
launch_button.click()
screenshot(page, "WorkspaceLaunching")
page.wait_for_selector(self.WORKSPACE_SPINNER, state="visible")
# workspace can take a while to launch
page.wait_for_selector(self.WORKSPACE_IFRAME, state="visible", timeout=600000)
page.frame_locator(self.WORKSPACE_IFRAME).locator(
"//div[@aria-label='Top Menu']"
).wait_for(timeout=60000)

def open_python_notebook(self, page: Page):
"""Open Python notebook in the workspace"""
Expand All @@ -97,22 +95,23 @@ def open_python_notebook(self, page: Page):
command_prompt.wait_for(state="visible")
screenshot(page, "PythonNotebook")

def run_command_in_notebook(self, page: Page, command: str = ""):
command_input = page.frame_locator(self.WORKSPACE_IFRAME).locator(
self.NB_CELL_INPUT
def run_command_in_notebook(self, page: Page, command: str = "!gen3 --help"):
command_input = (
page.frame_locator(self.WORKSPACE_IFRAME).locator(self.NB_CELL_INPUT).last
)
if command == "":
command = "gen3 --help"
command_input.press_sequentially(command)
screenshot(page, "NotebookCellInput")
page.frame_locator(self.WORKSPACE_IFRAME).locator(
self.NB_RUN_CELL_BUTTON
).click()
output = page.frame_locator(self.WORKSPACE_IFRAME).locator(self.NB_CELL_OUTPUT)
output = (
page.frame_locator(self.WORKSPACE_IFRAME).locator(self.NB_CELL_OUTPUT).last
)
output.wait_for(state="visible")
screenshot(page, "NotebookCellOutput")
return output.text_content()

def terminate_workspace(self, page: Page):
page.locator(self.TERMINATE_BUTTON).click()
page.locator(self.YES_BUTTON).click()
page.locator(self.WORKSPACE_OPTIONS).wait_for(timeout=300000)
6 changes: 5 additions & 1 deletion gen3-integration-tests/tests/test_discoverypage.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ def test_study_publish_search_export(self, page):
page, "(Tutorial) Bacpac Synthetic Data Analysis Notebook"
)
screenshot(page, "WorkspaceLaunched")

# Open Python notebook and run gen3 commands
workspace_page.open_python_notebook(page)
command = "!pip install -U gen3"
command = "!pip install -U gen3==4.24.1" # TODO: Fix the workspace image in jenkins envs, use jupyterlab
logger.info(f"Running in jupyter notebook: {command}")
result = workspace_page.run_command_in_notebook(page, command)
command = f"!gen3 drs-pull object {self.variables['did']}"
logger.info(f"Running in jupyter notebook: {command}")
result = workspace_page.run_command_in_notebook(page, command)
logger.info(f"Result: {result}")

# Terminate workspace
workspace_page.terminate_workspace(page)
screenshot(page, "WorkspaceTerminated")
9 changes: 6 additions & 3 deletions gen3-integration-tests/tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ def test_workspace_drs_pull(self, page):
workspace_page.launch_workspace(page)
"""opens python kernel in notebook"""
workspace_page.open_python_notebook(page)
"""executes gen3 --help command"""
command = "!gen3 --help"
logger.info(f"Running command in jupyter notebook: {command}")
command = "!pip install -U gen3==4.24.1"
logger.info(f"Running in jupyter notebook: {command}")
result = workspace_page.run_command_in_notebook(page, command)
logger.info(
"Running command in jupyter notebook: !gen3 --help"
) # default command
result = workspace_page.run_command_in_notebook(page)
logger.info(f"Result: {result}")
"""terminates the workspace after executing the command"""
Expand Down

0 comments on commit 41e44b3

Please sign in to comment.