Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "flaggle"
name = "python_flaggle"
version = "0.2.0"
description = ""
authors = [
Expand Down
4 changes: 2 additions & 2 deletions flaggle/__init__.py → python_flaggle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flaggle.flaggle import Flaggle
from flaggle.flag import Flag, FlagOperation, FlagType
from python_flaggle.flaggle import Flaggle
from python_flaggle.flag import Flag, FlagOperation, FlagType

__all__ = ["FlagType", "FlagOperation", "Flag", "Flaggle"]
__version__ = "0.2.0"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion flaggle/flaggle.py → python_flaggle/flaggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from requests import RequestException, get

from flaggle.flag import Flag
from python_flaggle.flag import Flag

logger = getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pytest import raises

from flaggle import Flag, FlagOperation, FlagType
from python_flaggle import Flag, FlagOperation, FlagType


class TestFlagType:
Expand Down Expand Up @@ -311,7 +311,7 @@ def test_from_json_no_flag_name(self):
]
}

with patch("flaggle.flag.logger.warning") as mock_warning:
with patch("python_flaggle.flag.logger.warning") as mock_warning:
flag = Flag.from_json(json_data)
assert flag == {}
mock_warning.assert_called_once_with("Found flag without name, skipping")
Expand Down
10 changes: 5 additions & 5 deletions tests/test_flaggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from unittest.mock import Mock, patch


from flaggle import Flag, Flaggle
from python_flaggle import Flag, Flaggle


class TestFlaggle:
def test_init(self):
with patch("flaggle.flaggle.get") as mock_get:
with patch("python_flaggle.flaggle.get") as mock_get:
mock_response = Mock()
mock_response.status_code = 200
mock_response.json.return_value = {
Expand Down Expand Up @@ -76,7 +76,7 @@ def status_code(self):
def text(self):
return '{"flags": [{"name": "flag1", "value": true}]}'

monkeypatch.setattr("flaggle.flaggle.get", lambda *a, **k: MockResponse())
monkeypatch.setattr("python_flaggle.flaggle.get", lambda *a, **k: MockResponse())
flags = self.flaggle._fetch_flags()
assert "flag1" in flags

Expand All @@ -86,7 +86,7 @@ def raise_exc(*a, **k):

raise RequestException("fail")

monkeypatch.setattr("flaggle.flaggle.get", raise_exc)
monkeypatch.setattr("python_flaggle.flaggle.get", raise_exc)
assert self.flaggle._fetch_flags() == {}

def test_fetch_flags_key_error(self, monkeypatch):
Expand All @@ -105,7 +105,7 @@ def status_code(self):
def text(self):
return "{}"

monkeypatch.setattr("flaggle.flaggle.get", lambda *a, **k: MockResponse())
monkeypatch.setattr("python_flaggle.flaggle.get", lambda *a, **k: MockResponse())
assert self.flaggle._fetch_flags() == {}

def test_update_with_data(self, monkeypatch):
Expand Down
16 changes: 8 additions & 8 deletions tests/test_flaggle_extra.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import threading
from unittest.mock import MagicMock, patch

from flaggle import Flag, Flaggle
from python_flaggle import Flag, Flaggle


def test_flaggle_init_sets_last_update_and_flags(monkeypatch):
Expand All @@ -21,15 +21,15 @@ def status_code(self):
def text(self):
return '{"flags": [{"name": "flag", "value": true}]}'

monkeypatch.setattr("flaggle.flaggle.get", lambda *a, **k: MockResponse())
monkeypatch.setattr("python_flaggle.flaggle.get", lambda *a, **k: MockResponse())
f = Flaggle("http://x", interval=1, default_flags={"f": Flag("f", True)})
assert isinstance(f.last_update, type(f._last_update))
assert isinstance(f.flags, dict)


def test_flaggle_update_uses_default_flags_on_empty(monkeypatch):
monkeypatch.setattr(
"flaggle.flaggle.get",
"python_flaggle.flaggle.get",
lambda *a, **k: MagicMock(
json=lambda: {"flags": []},
raise_for_status=lambda: None,
Expand All @@ -40,14 +40,14 @@ def test_flaggle_update_uses_default_flags_on_empty(monkeypatch):
f = Flaggle("http://x", interval=1, default_flags={"f": Flag("f", True)})
# forcibly clear flags to test fallback
f._flags = {"f": Flag("f", True)}
with patch("flaggle.flaggle.Flag.from_json", return_value={}):
with patch("python_flaggle.flaggle.Flag.from_json", return_value={}):
f._update()
assert f._flags == {"f": Flag("f", True)} or f._flags == {}


def test_flaggle_schedule_update_starts_thread(monkeypatch):
monkeypatch.setattr(
"flaggle.flaggle.get",
"python_flaggle.flaggle.get",
lambda *a, **k: MagicMock(
json=lambda: {"flags": []},
raise_for_status=lambda: None,
Expand All @@ -63,7 +63,7 @@ def test_flaggle_schedule_update_starts_thread(monkeypatch):

def test_flaggle_recurring_update_calls(monkeypatch):
monkeypatch.setattr(
"flaggle.flaggle.get",
"python_flaggle.flaggle.get",
lambda *a, **k: MagicMock(
json=lambda: {"flags": []},
raise_for_status=lambda: None,
Expand All @@ -86,14 +86,14 @@ def raise_exc(*a, **k):

raise RequestException("fail")

monkeypatch.setattr("flaggle.flaggle.get", raise_exc)
monkeypatch.setattr("python_flaggle.flaggle.get", raise_exc)
f = Flaggle("http://x", interval=1, default_flags={"f": Flag("f", True)})
assert f._fetch_flags() == {}


def test_flaggle_properties(monkeypatch):
monkeypatch.setattr(
"flaggle.flaggle.get",
"python_flaggle.flaggle.get",
lambda *a, **k: MagicMock(
json=lambda: {"flags": []},
raise_for_status=lambda: None,
Expand Down