Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FreeBSD #69

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plex_auto_languages/utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
from collections.abc import Mapping
import yaml
import warnings

from plex_auto_languages.utils.logger import get_logger
from plex_auto_languages.exceptions import InvalidConfiguration
Expand Down Expand Up @@ -51,6 +52,9 @@ def get_data_directory(app_name: str):
return str(home / f".local/share/{app_name}")
if sys.platform == "darwin":
return str(home / f"Library/Application Support/{app_name}")
if os.uname()[0] == "FreeBSD":
return str(home / f".local/share/{app_name}")
warnings.warn("Warning: Unsupported Operating System!")
return None


Expand Down
13 changes: 12 additions & 1 deletion tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import logging
import tempfile
import warnings
from unittest.mock import patch

from plex_auto_languages.exceptions import InvalidConfiguration
Expand All @@ -29,8 +30,14 @@ def test_get_data_directory():
sys.platform = "darwin"
assert get_data_directory("test") == os.path.expanduser("~/Library/Application Support/test")

sys.platform = "freebsdxx"
with patch("os.uname", return_value=["FreeBSD"]):
assert get_data_directory("test") == os.path.expanduser("~/.local/share/test")

sys.platform = "unknown_platform"
assert get_data_directory("test") is None
with patch.object(warnings, "warn") as mocked_warn:
assert get_data_directory("test") is None
mocked_warn.assert_called_once()

with patch("plex_auto_languages.utils.configuration.is_docker", return_value=True):
sys.platform = "win32"
Expand All @@ -42,6 +49,10 @@ def test_get_data_directory():
sys.platform = "darwin"
assert get_data_directory("test") == "/config"

sys.platform = "freebsdxx"
with patch("os.uname", return_value=["FreeBSD"]):
assert get_data_directory("test") == "/config"

sys.platform = "unknown_platform"
assert get_data_directory("test") == "/config"
sys.platform = initial_platform
Expand Down