hass.tibber_prices/scripts/sync-hacs
Julian Pawlowski f60b5990ae test: add pytest framework and midnight-crossing tests
Set up pytest with Home Assistant support and created 6 tests for
midnight-crossing period logic (5 unit tests + 1 integration test).

Added pytest configuration, test dependencies, test runner script
(./scripts/test), and comprehensive tests for group_periods_by_day()
and midnight turnover consistency.

All tests pass in 0.12s.

Impact: Provides regression testing for midnight-crossing period bugs.
Tests validate periods remain visible across midnight turnover.
2025-11-21 23:47:01 +00:00

62 lines
1.8 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# script/sync-hacs: Sync HACS-installed integrations to custom_components/
set -e
cd "$(dirname "$0")/.."
echo "==> Syncing HACS-installed integrations..."
# Check if config/custom_components exists
if [ ! -d "config/custom_components" ]; then
echo " No config/custom_components directory found"
exit 0
fi
# Clean up broken symlinks (where target no longer exists)
cleaned=0
if [ -d "custom_components" ]; then
for link in custom_components/*; do
# Skip if not a symlink
if [ ! -L "$link" ]; then
continue
fi
# Check if symlink target exists
if [ ! -e "$link" ]; then
component=$(basename "$link")
rm "$link"
echo " 🗑️ Removed broken link: $component"
cleaned=$((cleaned + 1))
fi
done
fi
# Create symlinks for all integrations in config/custom_components/
# except those that already exist in custom_components/
synced=0
for dir in config/custom_components/*/; do
component=$(basename "$dir")
target="custom_components/$component"
# Skip if already exists and is not a symlink (don't touch tibber_prices)
if [ -e "$target" ] && [ ! -L "$target" ]; then
continue
fi
# Create or update symlink
ln -sf "${PWD}/config/custom_components/$component" "$target"
echo " ✓ Linked: $component"
synced=$((synced + 1))
done
if [ $synced -eq 0 ] && [ $cleaned -eq 0 ]; then
echo " No changes needed"
elif [ $synced -gt 0 ] && [ $cleaned -eq 0 ]; then
echo " ✓ Synced $synced integration(s)"
elif [ $synced -eq 0 ] && [ $cleaned -gt 0 ]; then
echo " ✓ Cleaned up $cleaned broken link(s)"
else
echo " ✓ Synced $synced integration(s), cleaned up $cleaned broken link(s)"
fi