Added Application HolidayViewer

This commit is contained in:
Kodjo Sossouvi
2025-06-27 07:26:58 +02:00
parent 66ea45f501
commit 9f4b8ab4d0
87 changed files with 3756 additions and 212 deletions

View File

@@ -176,7 +176,7 @@ def test_add_table_success(db, settings_manager_with_existing_repo):
def test_add_table_repository_not_found(db):
"""Test adding a table to a non-existent repository."""
with pytest.raises(ValueError, match="Repository 'NonExistentRepo' does not exist."):
with pytest.raises(NameError, match="Repository 'NonExistentRepo' does not exist."):
db.add_table("NonExistentRepo", "NewTable")
@@ -210,13 +210,13 @@ def test_modify_table_success(db, settings_manager_with_existing_repo):
def test_modify_table_repository_not_found(db):
"""Test modifying a table in a non-existent repository."""
with pytest.raises(ValueError, match="Repository 'NonExistentRepo' does not exist."):
with pytest.raises(NameError, match="Repository 'NonExistentRepo' does not exist."):
db.modify_table("NonExistentRepo", "Table1", "NewTable")
def test_modify_table_not_found(db, settings_manager_with_existing_repo):
"""Test modifying a non-existent table."""
with pytest.raises(ValueError, match="Table 'NonExistentTable' does not exist in repository 'ExistingRepo'."):
with pytest.raises(NameError, match="Table 'NonExistentTable' does not exist in repository 'ExistingRepo'."):
db.modify_table("ExistingRepo", "NonExistentTable", "NewTable")
@@ -249,13 +249,13 @@ def test_remove_table_success(db, settings_manager_with_existing_repo):
def test_remove_table_repository_not_found(db):
"""Test removing a table from a non-existent repository."""
with pytest.raises(ValueError, match="Repository 'NonExistentRepo' does not exist."):
with pytest.raises(NameError, match="Repository 'NonExistentRepo' does not exist."):
db.remove_table("NonExistentRepo", "Table1")
def test_remove_table_not_found(db, settings_manager_with_existing_repo):
"""Test removing a non-existent table."""
with pytest.raises(ValueError, match="Table 'NonExistentTable' does not exist in repository 'ExistingRepo'."):
with pytest.raises(NameError, match="Table 'NonExistentTable' does not exist in repository 'ExistingRepo'."):
db.remove_table("ExistingRepo", "NonExistentTable")
@@ -273,3 +273,41 @@ def test_remove_table_empty_repository_name(db):
db.remove_table("", "Table1")
with pytest.raises(ValueError, match="Repository name cannot be empty."):
db.remove_table(None, "Table1")
def test_repository_exists(db, settings_manager):
assert db.exists_repository("SomeRepo") is False
settings = RepositoriesSettings()
repo = Repository(name="SomeRepo", tables=["Table1"])
settings.repositories.append(repo)
settings_manager.save(db.session, REPOSITORIES_SETTINGS_ENTRY, settings)
assert db.exists_repository("SomeRepo") is True
def test_repository_table(db, settings_manager_with_existing_repo):
assert db.exists_table("ExistingRepo", "SomeTable") is False
db.add_table("ExistingRepo", "SomeTable")
assert db.exists_table("ExistingRepo", "SomeTable") is True
def test_exists_table_fails_when_repo_doesnt_exist(db):
assert db.exists_table("NonExistentRepo", "SomeTable") is False
def test_ensure_exists(db, settings_manager):
settings = settings_manager.load(db.session, REPOSITORIES_SETTINGS_ENTRY, default=RepositoriesSettings())
assert len(settings.repositories) == 0
db.ensure_exists("SomeRepo", "SomeTable")
settings = settings_manager.load(db.session, REPOSITORIES_SETTINGS_ENTRY)
assert len(settings.repositories) == 1
assert settings.repositories[0].name == "SomeRepo"
assert settings.repositories[0].tables == ["SomeTable"]
db.ensure_exists("SomeRepo", "SomeTable") # as no effect when called twice
settings = settings_manager.load(db.session, REPOSITORIES_SETTINGS_ENTRY)
assert len(settings.repositories) == 1
assert settings.repositories[0].name == "SomeRepo"
assert settings.repositories[0].tables == ["SomeTable"]