Skip to content

Commit

Permalink
fix(tests): correctly patch filesystem on python 3.8
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss committed Jul 16, 2024
1 parent 1e15df3 commit 1367df2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/unit/test_juju_systemd_notices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import subprocess
import unittest
from pathlib import Path
from unittest.mock import AsyncMock, patch

from charms.operator_libs_linux.v0.juju_systemd_notices import (
Expand Down Expand Up @@ -98,7 +99,12 @@ def test_generate_hooks(self, mock_exists, _) -> None:
def test_generate_config(self, mock_exists) -> None:
"""Test that watch configuration file is generated correctly."""
with Patcher() as patcher:
patcher.fs.create_file("no-disk-path/watch.yaml")
# Set charm_dir to "/" because mocked charm_dir default
# `no-disk-path` does not exist within the fake filesystem.
# Tried creating `no-disk-path` in the fake filesystem, but
# the mocked objects could not find it.
self.harness.charm.framework.charm_dir = Path("/")
patcher.fs.create_file("watch.yaml")

# Scenario 1 - Generate success but no pre-existing watch configuration.
mock_exists.return_value = False
Expand Down

0 comments on commit 1367df2

Please sign in to comment.