Public repository: timo / mitch

Reader

A migration stitcher (therefore mitch) for PostgreSQL, SQLite, MariaDB, and others

mitch / tests / test_errors.py · 838 bytes · at 76a2c3d332a1 · raw

Outline: 3 definitions
1
from pathlib import Path
2
3
import pytest
4
5
from mitch.errors import DuplicateMigrationIdError, MissingMigrationError, NoProjectFound
6
from mitch.project import Project
7
8
9
def test_duplicate_migration_ids_raise():
10
    with pytest.raises(DuplicateMigrationIdError) as exc_info:
11
        Project.from_path(Path("tests/project-with-duplicate-ids"))
12
13
    duplicates = exc_info.value.duplicates
14
    assert "same-id" in duplicates
15
    assert len(duplicates["same-id"]) == 2
16
17
18
def test_missing_migration_error_message():
19
    project = Project.from_path(Path("tests/migrations"))
20
21
    with pytest.raises(MissingMigrationError) as exc_info:
22
        project.by_id("missing-id")
23
24
    assert "missing-id" in str(exc_info.value)
25
26
27
def test_no_project_found_error_message():
28
    error = NoProjectFound("missing/path")
29
    assert "missing/path" in str(error)