Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek's Macbook Pro authored and Abhishek's Macbook Pro committed May 11, 2024
1 parent bf0464d commit bffaf2b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
23 changes: 21 additions & 2 deletions tests/src/commands/test_annotate_and_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def test_click_on_annotated_html(self):
pass
test_file_view = self.test_file_view

with patch("os.path.exists") as mocked_os_path_exists, patch("sublime.load_settings") as mocked_load_settings, patch("PyRock.src.commands.annotate_and_test_runner.AnnotateAndTestRunnerCommand._run_test_command") as mocked_run_test_command:
with patch("os.path.exists") as mocked_os_path_exists, \
patch("sublime.load_settings") as mocked_load_settings, \
patch("sublime.Window.symbol_locations") as mocked_symbol_locations, \
patch("PyRock.src.commands.annotate_and_test_runner.AnnotateAndTestRunnerCommand._run_test_command") as mocked_run_test_command:

mocked_load_settings.return_value = {
"python_venv_path": "/Users/abhishek/venv/bin/activate",
Expand All @@ -62,6 +65,11 @@ def test_click_on_annotated_html(self):
}
mocked_os_path_exists.return_value = True

class TestSymbol:
path = test_file_view.file_name()
display_name = "tests/fixtures/test_fixture.py"
mocked_symbol_locations.return_value = [TestSymbol()]

self.test_runner_cmd.run(test_file_view)
self.test_runner_cmd._execute_test("0")

Expand All @@ -85,14 +93,25 @@ def test_run_test_command(self):
pass
test_file_view = self.test_file_view

with patch("PyRock.src.commands.output_panel.OutputPanel.show") as mocked_panel_show, patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config:
with patch("PyRock.src.commands.output_panel.OutputPanel.show") as mocked_panel_show, \
patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config, \
patch("subprocess.Popen") as mocked_process:
mocked_get_test_config.return_value = {
"enabled": True,
"test_framework": "pytest",
"working_directory": PyRockConstants.PACKAGE_TEST_FIXTURES_DIR,
"test_runner_command": ["pytest"]
}

class TestProcess:
returncode = -1
stdout = []

def wait(self):
pass

mocked_process.return_value = TestProcess()

self.test_runner_cmd.run(test_file_view)
self.test_runner_cmd._execute_test("0")

Expand Down
33 changes: 29 additions & 4 deletions tests/src/commands/test_copy_test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def test_copy_django_class_test_path(self):
pass
test_file_view = self.test_file_view

with patch("sublime.load_settings") as mocked_load_settings, patch("os.path.exists") as mocked_os_path_exists:
with patch("sublime.load_settings") as mocked_load_settings, \
patch("os.path.exists") as mocked_os_path_exists, \
patch("sublime.Window.symbol_locations") as mocked_symbol_locations:

mocked_load_settings.return_value = {
"python_venv_path": "/Users/abhishek/venv/bin/activate",
Expand All @@ -37,6 +39,11 @@ def test_copy_django_class_test_path(self):
}
mocked_os_path_exists.return_value = True

class TestSymbol:
path = test_file_view.file_name()
display_name = "tests/fixtures/test_fixture.py"
mocked_symbol_locations.return_value = [TestSymbol()]

test_file_view.sel().clear()
test_file_view.sel().add(sublime.Region(53, 63))

Expand All @@ -60,7 +67,8 @@ def test_copy_django_class_method_test_path(self):
pass
test_file_view = self.test_file_view

with patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config:
with patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config, \
patch("sublime.Window.symbol_locations") as mocked_symbol_locations:

mocked_get_test_config.return_value = {
"enabled": True,
Expand All @@ -69,6 +77,11 @@ def test_copy_django_class_method_test_path(self):
"test_runner_command": ["pytest"]
}

class TestSymbol:
path = test_file_view.file_name()
display_name = "tests/fixtures/test_fixture.py"
mocked_symbol_locations.return_value = [TestSymbol()]

test_file_view.sel().clear()
test_file_view.sel().add(sublime.Region(83, 105))

Expand Down Expand Up @@ -125,14 +138,20 @@ def test_copy_pytest_class_test_path(self):
pass
test_file_view = self.test_file_view

with patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config:
with patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config, \
patch("sublime.Window.symbol_locations") as mocked_symbol_locations:
mocked_get_test_config.return_value = {
"enabled": True,
"test_framework": "pytest",
"working_directory": PyRockConstants.PACKAGE_TEST_FIXTURES_DIR,
"test_runner_command": ["pytest"]
}

class TestSymbol:
path = test_file_view.file_name()
display_name = "tests/fixtures/test_fixture.py"
mocked_symbol_locations.return_value = [TestSymbol()]

test_file_view.sel().clear()
test_file_view.sel().add(sublime.Region(53, 63))

Expand All @@ -156,14 +175,20 @@ def test_copy_pytest_class_method_test_path(self):
pass
test_file_view = self.test_file_view

with patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config:
with patch("PyRock.src.settings.SettingsTestConfigField._get_value") as mocked_get_test_config, \
patch("sublime.Window.symbol_locations") as mocked_symbol_locations:
mocked_get_test_config.return_value = {
"enabled": True,
"test_framework": "pytest",
"working_directory": PyRockConstants.PACKAGE_TEST_FIXTURES_DIR,
"test_runner_command": ["pytest"]
}

class TestSymbol:
path = test_file_view.file_name()
display_name = "tests/fixtures/test_fixture.py"
mocked_symbol_locations.return_value = [TestSymbol()]

test_file_view.sel().clear()
test_file_view.sel().add(sublime.Region(83, 105))

Expand Down

0 comments on commit bffaf2b

Please sign in to comment.