Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: python tests/test_wallet_validation.py

- name: Run asset files tests
run: SKIP_PNG_SIZE_CHECK=1 python tests/test_assets.py
run: SKIP_PNG_SIZE_CHECK=1 SKIP_EXTRA_IMAGES_CHECK=1 python tests/test_assets.py

- name: Run proxy URL tests
run: python tests/test_proxy_urls.py
Expand Down
Binary file added assets/okxminiwallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 36 additions & 10 deletions tests/test_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,35 @@ def test_asset_files():

passed = 0
failed = 0
warnings = 0
problems = []
warning_problems = []

# Check if size validation is disabled
skip_size_check = os.getenv('SKIP_PNG_SIZE_CHECK', '').lower() in ('1', 'true', 'yes')
# Check if extra images check is disabled (warnings instead of errors)
skip_extra_images_check = os.getenv('SKIP_EXTRA_IMAGES_CHECK', '').lower() in ('1', 'true', 'yes')

def check(condition, message, problem=None):
nonlocal passed, failed
def check(condition, message, problem=None, is_warning=False):
nonlocal passed, failed, warnings
if test(condition, message):
passed += 1
else:
failed += 1
if problem:
problems.append(problem)
if is_warning:
warnings += 1
if problem:
warning_problems.append(problem)
else:
failed += 1
if problem:
problems.append(problem)

print("=" * 50)
print("ASSET FILES VALIDATION TESTS")
if skip_size_check:
print("(PNG size validation disabled)")
if skip_extra_images_check:
print("(Extra images check as warnings)")
print("=" * 50)

# Load wallets data
Expand Down Expand Up @@ -126,7 +137,10 @@ def check(condition, message, problem=None):
if assets_dir.exists():
for asset_file in assets_dir.glob("*.png"):
if asset_file.name not in expected_files:
check(False, f"Unused asset file: {asset_file.name}", f"REMOVE: assets/{asset_file.name} (not used by any wallet)")
if skip_extra_images_check:
check(False, f"Unused asset file: {asset_file.name}", f"REMOVE: assets/{asset_file.name} (not used by any wallet)", is_warning=True)
else:
check(False, f"Unused asset file: {asset_file.name}", f"REMOVE: assets/{asset_file.name} (not used by any wallet)")

# Show problems
if problems:
Expand All @@ -136,16 +150,28 @@ def check(condition, message, problem=None):
for problem in problems:
print(f" {problem}")

# Show warnings
if warning_problems:
print(f"\nWarning - Files that could be cleaned up:")
print()
for problem in warning_problems:
print(f" {problem}")

# Summary
print("\n" + "=" * 50)
print("SUMMARY")
print("=" * 50)
print(f"PASSED: {passed}")
print(f"FAILED: {failed}")
print(f"TOTAL: {passed + failed}")
print(f"PASSED: {passed}")
print(f"FAILED: {failed}")
if warnings > 0:
print(f"WARNINGS: {warnings}")
print(f"TOTAL: {passed + failed + warnings}")

if failed == 0:
print("\nALL TESTS PASSED")
if warnings > 0:
print(f"\nALL TESTS PASSED (with {warnings} warnings)")
else:
print("\nALL TESTS PASSED")
return True
else:
print(f"\n{failed} TESTS FAILED")
Expand Down