Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-mi committed Aug 15, 2023
1 parent e47a8aa commit f2c4d7b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def helper(file):

execute_for_each_multithreaded(file_paths, lambda x: helper(x))

def create_python_project_wheel(self, project_location):
def _create_python_project_wheel(self, project_location):
dist_location = f"{project_location}/dist"
execute_shell_command(f"rm {dist_location}/* 2>/dev/null || true")

Expand Down
7 changes: 0 additions & 7 deletions rocket/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,3 @@ def extract_python_files_from_folder(path):
py_files.append(os.path.join(root, file))

return py_files


def append_index_urls_to_cmd(cmd, index_urls):
if index_urls:
return f"{' '.join(index_urls)} {cmd}"
else:
return cmd
16 changes: 9 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@


@pytest.fixture()
def python_rocket() -> Rocket:
rocket = Rocket()
def python_project_path() -> str:
test_dir = os.path.dirname(os.path.realpath(__file__))
project_path = os.path.join(test_dir, "resources", "python-test")
rocket.project_location = project_path
return rocket
return project_path


@pytest.fixture()
def poetry_rocket() -> Rocket:
rocket = Rocket()
def poetry_project_path() -> str:
test_dir = os.path.dirname(os.path.realpath(__file__))
project_path = os.path.join(test_dir, "resources", "poetry-test")
rocket.project_location = project_path
return project_path


@pytest.fixture()
def rocket() -> Rocket:
rocket = Rocket()
return rocket
32 changes: 30 additions & 2 deletions tests/test_rocket.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
def test_dummy():
assert 42 == 42
from rocket.rocket import Rocket


def test_create_python_wheel_from_python_project_successful(rocket: Rocket, python_project_path: str):
"""
Test if DB Rocket can build a python project
"""
wheel_path, wheel_file = rocket._create_python_project_wheel(python_project_path)
assert wheel_file
assert wheel_path


def test_create_python_wheel_from_poetry_project_successful(rocket: Rocket, poetry_project_path: str):
"""
Test if DB Rocket can build a poetry project
"""
wheel_path, wheel_file = rocket._create_python_project_wheel(poetry_project_path)
assert wheel_file
assert wheel_path


def test_create_python_wheel_from_temp_folder_raises_exception(rocket: Rocket):
"""
Test if DB Rocket will raise an error if project is not a supported project
"""
try:
wheel_path, wheel_file = rocket._create_python_project_wheel("/tmp")
except:
assert True

0 comments on commit f2c4d7b

Please sign in to comment.