41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from core.dev3.provenance import inventory
|
|
from core.provenance import ProvenanceError
|
|
|
|
|
|
class InventoryTests(unittest.TestCase):
|
|
def test_inventory_captures_content_modes_and_rejects_symlinks(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root = Path(directory)
|
|
script = root / "entry"
|
|
script.write_text("first")
|
|
original = inventory(root)
|
|
script.chmod(0o700)
|
|
self.assertNotEqual(inventory(root), original)
|
|
script.write_text("second")
|
|
self.assertNotEqual(inventory(root)["entry"][0], original["entry"][0])
|
|
(root / "link").symlink_to(script)
|
|
with self.assertRaises(ProvenanceError):
|
|
inventory(root)
|
|
|
|
|
|
class LaravelMigrationPathTests(unittest.TestCase):
|
|
def test_inventory_matches_registered_directory_globs(self):
|
|
from core.compatibility import is_laravel_migration_path
|
|
|
|
for path in (
|
|
"Modules/Billing/database/Migrations/0001_add_invoice.php",
|
|
"modules/Orders/Database/migrations/0002_add_order.php",
|
|
"database/migrations/0003_add_user.php",
|
|
):
|
|
self.assertTrue(is_laravel_migration_path(path), path)
|
|
for path in (
|
|
"Modules/Billing/database/Migrations/nested/0001_add_invoice.php",
|
|
"database/migrations/README.php",
|
|
"database/migrations/nested/0003_add_user.php",
|
|
):
|
|
self.assertFalse(is_laravel_migration_path(path), path)
|