Skip to content

Commit 13c2016

Browse files
feat(utils/is_oss): Add a function to check oss deployment mode (#44)
* feat(utils/is_oss): Add a function to check deployment mode * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 29b3256 commit 13c2016

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/common/core/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def is_saas() -> bool:
3737
return pathlib.Path("./SAAS_DEPLOYMENT").exists()
3838

3939

40+
def is_oss() -> bool:
41+
return not (is_enterprise() or is_saas())
42+
43+
4044
@lru_cache()
4145
def has_email_provider() -> bool:
4246
match settings.EMAIL_BACKEND:

tests/unit/common/core/test_utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
get_version_info,
1111
has_email_provider,
1212
is_enterprise,
13+
is_oss,
1314
is_saas,
1415
)
1516

@@ -25,6 +26,27 @@ def clear_lru_caches() -> Generator[None, None, None]:
2526
is_saas.cache_clear()
2627

2728

29+
def test__is_oss_for_enterprise_returns_false(fs: FakeFilesystem) -> None:
30+
# Given
31+
fs.create_file("./ENTERPRISE_VERSION")
32+
33+
# Then
34+
assert is_oss() is False
35+
36+
37+
def test__is_oss_for_saas_returns_false(fs: FakeFilesystem) -> None:
38+
# Given
39+
fs.create_file("./SAAS_DEPLOYMENT")
40+
41+
# Then
42+
assert is_oss() is False
43+
44+
45+
def test__is_oss_for_oss_returns_true(fs: FakeFilesystem) -> None:
46+
# Then
47+
assert is_oss() is True
48+
49+
2850
def test_get_version_info(fs: FakeFilesystem) -> None:
2951
# Given
3052
expected_manifest_contents = {

0 commit comments

Comments
 (0)