Skip to content

Commit e181d86

Browse files
committed
avoid circular imports, fix tests
1 parent 4229b4b commit e181d86

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed
File renamed without changes.

src/common/core/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from environs import Env
1212

1313
from common.core.cli import healthcheck
14-
from common.prometheus.constants import DEFAULT_PROMETHEUS_MULTIPROC_DIR
14+
from common.core.constants import DEFAULT_PROMETHEUS_MULTIPROC_DIR
1515

1616
logger = logging.getLogger(__name__)
1717

tests/integration/core/test_main.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import os
21
import subprocess
3-
from pathlib import Path
42

53
import django
64
import pytest
@@ -111,32 +109,43 @@ def test_main__healthcheck_http__server_invalid_response__runs_expected(
111109
main(argv)
112110

113111

114-
def test_main__prometheus_multiproc_remove_dir_on_exit_default__expected(
112+
def test_main__prometheus_multiproc_remove_dir_on_start_default__expected(
115113
monkeypatch: pytest.MonkeyPatch,
114+
fs: FakeFilesystem,
116115
) -> None:
117116
# Given
118117
monkeypatch.delenv("PROMETHEUS_MULTIPROC_DIR_KEEP", raising=False)
119118

119+
fs.create_file(
120+
"/tmp/flagsmith-prometheus/some_metric_file.db",
121+
create_missing_dirs=True,
122+
)
123+
120124
# When
121125
main(["flagsmith"])
122126

123127
# Then
124-
assert not Path(os.environ["PROMETHEUS_MULTIPROC_DIR"]).exists()
128+
assert not fs.exists("/tmp/flagsmith-prometheus/some_metric_file.db")
125129

126130

127-
def test_main__prometheus_multiproc_remove_dir_on_exit_true__expected(
131+
def test_main__prometheus_multiproc_remove_dir_on_start_true__expected(
128132
monkeypatch: pytest.MonkeyPatch,
129133
fs: FakeFilesystem,
130134
) -> None:
131135
# Given
132-
monkeypatch.delenv("PROMETHEUS_MULTIPROC_DIR")
136+
monkeypatch.delenv("PROMETHEUS_MULTIPROC_DIR", raising=False)
133137
monkeypatch.setenv("PROMETHEUS_MULTIPROC_DIR_KEEP", "true")
134138

139+
fs.create_file(
140+
"/tmp/flagsmith-prometheus/some_metric_file.db",
141+
create_missing_dirs=True,
142+
)
143+
135144
# When
136145
main(["flagsmith"])
137146

138147
# Then
139-
assert Path(os.environ["PROMETHEUS_MULTIPROC_DIR"]).exists()
148+
assert fs.exists("/tmp/flagsmith-prometheus/some_metric_file.db")
140149

141150

142151
def test_main__no_django_configured__expected_0(

0 commit comments

Comments
 (0)