Skip to content

Commit

Permalink
test documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKalema committed May 27, 2024
1 parent b892cf8 commit 339ce0e
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions tests/test_common_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,35 @@
from potholeClassifier.utils.common import *
from potholeClassifier.constants import *
from box import ConfigBox
import os
import tempfile
import shutil
from io import BytesIO
from unittest.mock import patch


def test_read_yaml_valid_file() -> None:
"""
Test that the read_yaml function correctly reads a valid YAML file and
returns an instance of the ConfigBox class.
Steps:
1. Call read_yaml with CONFIG_FILE_PATH.
2. Assert that the result is an instance of ConfigBox.
Expected Outcome:
The function should return an object of type ConfigBox.
"""
result = read_yaml(CONFIG_FILE_PATH)
assert isinstance(result, ConfigBox)


def test_read_yaml_nonexistent_file() -> None:
"""
Test that the read_yaml function raises a FileNotFoundError when provided
with a path to a non-existent file.
Steps:
1. Use pytest.raises to catch a FileNotFoundError.
2. Call read_yaml with the EMPTY_FILE_PATH.
Expected Outcome:
The function should raise a FileNotFoundError.
"""
with pytest.raises(FileNotFoundError):
read_yaml(Path(EMPTY_FILE_PATH))

0 comments on commit 339ce0e

Please sign in to comment.