Skip to content

Commit

Permalink
Added IDE markers for intellij and vscode (#57)
Browse files Browse the repository at this point in the history
* Added IDE markers for intellij

* pre-commit -a

* fixed record_test_run fixture

* added importlib-metadata

* removed importlib-metadata
updated additional_dependencies

* fixing requirements.txt

* fixing pre-commit

* fixing pre-commit

* fixing pre-commit

* fixing pre-commit

* fixing pre-commit

* fixing pre-commit

* fixing pre-commit

* fixing pre-commit

* Fixed marker
  • Loading branch information
midays authored Nov 20, 2023
1 parent 5f5058a commit 97b6ec8
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout to master
uses: actions/checkout@main
uses: actions/checkout@v2

- name: Setup python
uses: actions/setup-python@v2
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 23.11.0
hooks:
- id: black
args: [--safe, --quiet, --line-length, "100"]
args: [--safe, --quiet, --line-length, "200"]
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 3.9.0
rev: 6.1.0
hooks:
- id: flake8
args: ["--max-line-length=100"]
additional_dependencies: [flake8-typing-imports==1.7.0]
args: ["--max-line-length=200"]
additional_dependencies: [flake8-typing-imports==1.15.0.0]
exclude: |
(?x)^(
src/utils/data_control.py
Expand Down
45 changes: 21 additions & 24 deletions src/fixtures/video_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@

from src.utils.general import get_screen_size

RECORD_DIR = (
os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + "/archived_artifacts/videos"
)
RECORD_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + "/archived_artifacts/videos"


@pytest.fixture(autouse=True)
def record_test_run(ide, frame_rate=24):

if not pytest.record_video:
return

screen_size = get_screen_size()

run_time = datetime.now().strftime("%d-%m-%Y_%H:%M")
output_file = f"{RECORD_DIR}/{ide}_{run_time}.mp4"
cmd = (
f"ffmpeg -video_size {screen_size} -framerate {frame_rate} -f x11grab -i :0.0 {output_file}"
)
print("Executing command: " + cmd)
p = subprocess.Popen(cmd, shell=True)

yield

# Stop the recording
p.terminate()
# Ensure the process has terminated before exiting
p.wait()
def record_test_run(frame_rate=24):
p = None

if pytest.record_video:
ide = "intellij" if pytest.intellij else "vscode"

screen_size = get_screen_size()

run_time = datetime.now().strftime("%d-%m-%Y_%H:%M")
output_file = f"{RECORD_DIR}/{ide}_{run_time}.mp4"
cmd = f"ffmpeg -video_size {screen_size} -framerate " f"{frame_rate} -f x11grab -i :0.0 {output_file}"
print("Executing command: " + cmd)
p = subprocess.Popen(cmd, shell=True)

yield p
if p:
# Stop the recording
p.terminate()
# Ensure the process has terminated before exiting
p.wait()
2 changes: 0 additions & 2 deletions src/models/IDE/Intellij.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def open_mta_perspective(self):
self.click(self.config_run_region)

def run_simple_analysis(self, app_name, wait_for_analysis_finish=False):

self.refresh_configuration()

# Search for configuration name that has to be run
Expand All @@ -138,7 +137,6 @@ def run_simple_analysis(self, app_name, wait_for_analysis_finish=False):
)

def open_report_page(self, app_name):

self.click(self.config_run_region)
self.type_text(app_name)
self.press_keys("enter")
Expand Down
7 changes: 1 addition & 6 deletions src/models/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ def is_analysis_complete(self):
return False

def verify_story_points(self, html_file_location, expected_story_points, legacy=False):

locator = '//span[@class="points"]' if legacy else '//td[@data-label="Story points"]'

story_points_elements = find_elements_in_html_file(
Expand All @@ -300,8 +299,4 @@ def verify_story_points(self, html_file_location, expected_story_points, legacy=
)
found_story_points = [int(element.text) for element in story_points_elements]

assert set(found_story_points) == set(expected_story_points), (
f"Error: found story points are not as expected. "
f"\nExpected: [{expected_story_points}],"
f"\nInstead found : [{found_story_points}]"
)
assert set(found_story_points) == set(expected_story_points), f"Error: found story points are not as expected.\nExpected: [{expected_story_points}],\nInstead found : [{found_story_points}]"
3 changes: 3 additions & 0 deletions src/tests/intellij/test_advanced_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@pytest.mark.parametrize("app_name", ["weblogic_to_eap7"])
@pytest.mark.parametrize("ide", ["intellij"])
@pytest.mark.intellij
def test_csv_report_intellij(configurations, setup_intellij, app_name, analysis_data, ide):
"""Analysis test for IntelliJ using --exportCSV option"""
intellij = setup_intellij
Expand All @@ -28,6 +29,7 @@ def test_csv_report_intellij(configurations, setup_intellij, app_name, analysis_

@pytest.mark.parametrize("app_name", ["weblogic_to_eap7_skip_reports"])
@pytest.mark.parametrize("ide", ["intellij"])
@pytest.mark.intellij
def test_skip_reports_intellij(configurations, setup_intellij, app_name, analysis_data, ide):
"""Analysis test for IntelliJ using --skipReports option"""
intellij = setup_intellij
Expand All @@ -47,6 +49,7 @@ def test_skip_reports_intellij(configurations, setup_intellij, app_name, analysi

@pytest.mark.parametrize("app_name", ["weblogic_to_eap7_legacy_reports"])
@pytest.mark.parametrize("ide", ["intellij"])
@pytest.mark.intellij
def test_legacy_reports_intellij(configurations, setup_intellij, app_name, analysis_data, ide):
"""Analysis test for IntelliJ using --legacyReports option"""
intellij = setup_intellij
Expand Down
1 change: 1 addition & 0 deletions src/tests/intellij/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

@pytest.mark.parametrize("app_name", json.load(open(DATA_DIR + "analysis.json")))
@pytest.mark.parametrize("ide", ["intellij"])
@pytest.mark.intellij
def test_analysis_intellij(configurations, setup_intellij, app_name, analysis_data, ide):
"""
Analysis tests for intellij using various migration paths
Expand Down
1 change: 1 addition & 0 deletions src/tests/intellij/test_cancel_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@pytest.mark.parametrize("app_name", ["weblogic_to_eap7"])
@pytest.mark.parametrize("ide", ["intellij"])
@pytest.mark.intellij
def test_cancel_analysis_intellij(configurations, setup_intellij, app_name, analysis_data, ide):
"""
Tests the behaviour of canceling an analysis
Expand Down
2 changes: 2 additions & 0 deletions src/tests/intellij/test_cli_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from src.utils.ocr import find_all_sentence_occurrences


@pytest.mark.intellij
def test_empty_cli_path_intellij(setup_intellij):
"""
Tests the validation of empty cli path
Expand All @@ -22,6 +23,7 @@ def test_empty_cli_path_intellij(setup_intellij):
assert len(find_all_sentence_occurrences("")) > 0


@pytest.mark.intellij
@pytest.mark.parametrize("app_name", ["weblogic_to_eap7"])
def test_invalid_cli_path_intellij(
setup_intellij,
Expand Down
2 changes: 2 additions & 0 deletions src/tests/intellij/test_input_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from src.utils.ocr import find_all_sentence_occurrences


@pytest.mark.intellij
def test_empty_input_validation(setup_intellij):
"""
Analysis tests for intellij using various migration paths
Expand All @@ -22,6 +23,7 @@ def test_empty_input_validation(setup_intellij):
assert len(find_all_sentence_occurrences("Path to input required")) > 0


@pytest.mark.intellij
@pytest.mark.parametrize("app_name", ["weblogic_to_eap7"])
@pytest.mark.parametrize("ide", ["intellij"])
def test_invalid_input_validation(
Expand Down
67 changes: 11 additions & 56 deletions src/tests/intellij/test_miscellaneous_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# https://polarion.engineering.redhat.com/polarion/#/project/MigrationToolkitAppl/workitem?id=MTR-271


@pytest.mark.intellij
def test_plugin_info(setup_intellij):

plugin_short_name = "MTA" if pytest.mtr else "MTR"
plugin = "Applications" if pytest.mtr else "Runtimes"
"""
Expand All @@ -25,62 +25,17 @@ def test_plugin_info(setup_intellij):
intellij.open_plugin_info(plugin)

# assert all the following sentences are present in the panel
assert (
len(
find_all_sentence_occurrences(
f"The Migration Toolkit for {plugin} ({plugin_short_name}) plugin for IntelliJ",
),
)
> 0
), (
'the sentence "The Migration '
f"Toolkit for {plugin} ({plugin_short_name}) "
'plugin for IntelliJ" was not '
"found in the plugin info panel"
assert len(find_all_sentence_occurrences(f"The Migration Toolkit for {plugin} ({plugin_short_name}) plugin for IntelliJ")) > 0, (
'the sentence "The Migration ' f"Toolkit for {plugin} ({plugin_short_name}) " 'plugin for IntelliJ" was not ' "found in the plugin info panel"
)
assert (
len(find_all_sentence_occurrences("Platform-based IDEs")) > 0
), 'the sentence "Platform-based IDEs" was not found in the plugin info panel'
assert (
len(
find_all_sentence_occurrences(
"Provides tooling to accelerate application migration by marking",
),
)
> 0
), (
'the sentence "Provides tooling to '
"accelerate application migration "
'by marking" was not found in the '
"plugin info panel"
assert len(find_all_sentence_occurrences("Platform-based IDEs")) > 0, 'the sentence "Platform-based IDEs" was not found in the plugin info panel'
assert len(find_all_sentence_occurrences("Provides tooling to accelerate application migration by marking")) > 0, (
'the sentence "Provides tooling to ' "accelerate application migration " 'by marking" was not found in the ' "plugin info panel"
)
assert (
len(
find_all_sentence_occurrences(
"migration issues in the source code, provides guidance to fix the",
),
)
> 0
), (
'the sentence "migration issues '
"in the source code, "
'provides guidance to fix the" '
"was not found in the plugin info "
"panel"
assert len(find_all_sentence_occurrences("migration issues in the source code, provides guidance to fix the")) > 0, (
'the sentence "migration issues ' "in the source code, " 'provides guidance to fix the" ' "was not found in the plugin info " "panel"
)
assert (
len(
find_all_sentence_occurrences(
"issues, and offers automatic code replacement when possible",
),
)
> 0
), (
'the sentence "issues, and offers '
"automatic code replacement when "
'possible" was not found in the plugin '
"info panel"
assert len(find_all_sentence_occurrences("issues, and offers automatic code replacement when possible")) > 0, (
'the sentence "issues, and offers ' "automatic code replacement when " 'possible" was not found in the plugin ' "info panel"
)
assert (
len(find_all_sentence_occurrences("Read more about MTA here")) > 0
), 'the sentence "Read more about MTA here" was not found in the plugin info panel'
assert len(find_all_sentence_occurrences("Read more about MTA here")) > 0, 'the sentence "Read more about MTA here" was not found in the plugin info panel'
2 changes: 2 additions & 0 deletions src/tests/vscode/test_advanced_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

@pytest.mark.parametrize("app_name", ["thorntail_to_eapxp"])
@pytest.mark.parametrize("ide", ["vscode"])
@pytest.mark.vscode
def test_csv_report_vscode(configurations, setup_vscode, app_name, analysis_data, ide):
"""Analysis test for VScode using --exportCSV option"""
vscode = setup_vscode
Expand All @@ -25,6 +26,7 @@ def test_csv_report_vscode(configurations, setup_vscode, app_name, analysis_data

@pytest.mark.parametrize("app_name", ["weblogic_to_eap7_skip_reports"])
@pytest.mark.parametrize("ide", ["vscode"])
@pytest.mark.vscode
def test_skip_reports_vscode(configurations, setup_vscode, app_name, analysis_data, ide):
"""Analysis test for VScode using --skipReports option"""
vscode = setup_vscode
Expand Down
1 change: 1 addition & 0 deletions src/tests/vscode/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@pytest.mark.parametrize("app_name", json.load(open(DATA_DIR + "analysis.json")))
@pytest.mark.parametrize("ide", ["vscode"])
@pytest.mark.vscode
def test_analysis_vscode(configurations, setup_vscode, app_name, analysis_data, ide):
"""Analysis tests for VScode using various migration paths"""
vscode = setup_vscode
Expand Down
1 change: 0 additions & 1 deletion src/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def assert_valid_csv_file(file_path, **kwargs):


def find_elements_in_html_file(html_file_path, xpath):

if not os.path.exists(html_file_path):
raise Exception(f"File [{html_file_path}] does not exist!")

Expand Down

0 comments on commit 97b6ec8

Please sign in to comment.