"""Integration tests for the JobRepositoryInterface.""" from uuid import UUID import pytest from data_store.interfaces import JobRepositoryInterface from data_store.dto import Job def test_get_raises_not_implemented_if_not_overwritten( job_id_list: list[UUID], ) -> None: """Test that calling get on a subclass without get implemented raises NotImplementedError.""" class Incomplete(JobRepositoryInterface): """A class missing the get method.""" def get(self, job_id: UUID) -> Job | None: return super().get(job_id) # type: ignore def put(self, job: Job) -> None: return None def delete(self, job_id: UUID) -> None: return None def list_all(self) -> list[UUID]: return [] instance = Incomplete() with pytest.raises(NotImplementedError): instance.get(job_id_list[0]) def test_put_raises_not_implemented_if_not_overwritten( job: Job, ) -> None: """Test that calling put on a subclass without put implemented raises NotImplementedError.""" class Incomplete(JobRepositoryInterface): """A class missing the put method.""" def get(self, job_id: UUID) -> Job | None: return None def put(self, job: Job) -> None: return super().put(job) # type: ignore def delete(self, job_id: UUID) -> None: return None def list_all(self) -> list[UUID]: return [] instance = Incomplete() with pytest.raises(NotImplementedError): instance.put(job) def test_delete_raises_not_implemented_if_not_overwritten( job_id_list: list[UUID], ) -> None: """Test that calling delete on a subclass without delete implemented raises NotImplementedError.""" class Incomplete(JobRepositoryInterface): """A class missing the delete method.""" def get(self, job_id: UUID) -> Job | None: return None def put(self, job: Job) -> None: return None def delete(self, job_id: UUID) -> None: return super().delete(job_id) # type: ignore def list_all(self) -> list[UUID]: return [] instance = Incomplete() with pytest.raises(NotImplementedError): instance.delete(job_id_list[0]) def test_list_all_raises_not_implemented_if_not_overwritten() -> None: """Test that calling list_all on a subclass without list_all implemented raises NotImplementedError.""" class Incomplete(JobRepositoryInterface): """A class missing the list_all method.""" def get(self, job_id: UUID) -> Job | None: return None def put(self, job: Job) -> None: return None def delete(self, job_id: UUID) -> None: return None def list_all(self) -> list[UUID]: return super().list_all() # type: ignore instance = Incomplete() with pytest.raises(NotImplementedError): instance.list_all() # Allows local debugging by running file as script if __name__ == "__main__": pytest.main(["-s", "-v", __file__])