-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ankita Katiyar <[email protected]>
- Loading branch information
Showing
1 changed file
with
24 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,47 @@ | ||
import os | ||
import glob | ||
import zipfile | ||
import shutil # Import shutil for high-level file operations | ||
import subprocess | ||
import zipfile | ||
|
||
import pytest | ||
import shutil # Import shutil for high-level file operations | ||
|
||
|
||
# Define a fixture for setup and cleanup | ||
@pytest.fixture | ||
def cleanup(): | ||
# Setup can be done here if needed | ||
yield # This yields control to the test function | ||
# Cleanup: Remove the wheel_contents directory after the test | ||
shutil.rmtree('wheel_contents', ignore_errors=True) | ||
shutil.rmtree('dist', ignore_errors=True) | ||
shutil.rmtree("wheel_contents", ignore_errors=True) | ||
shutil.rmtree("dist", ignore_errors=True) | ||
|
||
|
||
# Use the fixture in your test by including it as a parameter | ||
def test_built_wheel_contains_expected_files(cleanup): | ||
# Build the project | ||
subprocess.run(['uv', 'build'], check=True) | ||
subprocess.run(["uv", "build"], check=True) | ||
|
||
# Find the wheel file | ||
wheel_files = glob.glob('dist/*.whl') | ||
wheel_files = glob.glob("dist/*.whl") | ||
assert wheel_files, "No wheel files found in dist/" | ||
wheel_file = wheel_files[0] | ||
|
||
# Unzip the wheel file using Python's zipfile module | ||
with zipfile.ZipFile(wheel_file, 'r') as zip_ref: | ||
zip_ref.extractall('wheel_contents') | ||
with zipfile.ZipFile(wheel_file, "r") as zip_ref: | ||
zip_ref.extractall("wheel_contents") | ||
|
||
# Check for the existence of CSS files in /assets/ folder | ||
css_files = glob.glob('wheel_contents/kedro_sphinx_theme/assets/styles/*.css') | ||
css_files = glob.glob("wheel_contents/kedro_sphinx_theme/assets/styles/*.css") | ||
assert css_files, "CSS files missing in /assets/" | ||
|
||
# Check for the existence of HTML files and theme.conf in /theme/kedro-sphinx-theme/ folder | ||
html_files = glob.glob('wheel_contents/kedro_sphinx_theme/theme/kedro-sphinx-theme/*.html') | ||
theme_conf_file = glob.glob('wheel_contents/kedro_sphinx_theme/theme/kedro-sphinx-theme/theme.conf') | ||
|
||
# Check for the existence of HTML files and theme.conf in /theme folder | ||
html_files = glob.glob( | ||
"wheel_contents/kedro_sphinx_theme/theme/kedro-sphinx-theme/*.html" | ||
) | ||
theme_conf_file = glob.glob( | ||
"wheel_contents/kedro_sphinx_theme/theme/kedro-sphinx-theme/theme.conf" | ||
) | ||
|
||
# Assert that HTML files and theme.conf exist | ||
assert html_files, "HTML files missing in /theme/kedro-sphinx-theme/" | ||
assert theme_conf_file, "theme.conf missing in /theme/kedro-sphinx-theme/" | ||
assert theme_conf_file, "theme.conf missing in /theme/kedro-sphinx-theme/" |