launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29287
[Merge] ~andrey-fedoseev/launchpad:snap-base-features into launchpad:master
Andrey Fedoseev has proposed merging ~andrey-fedoseev/launchpad:snap-base-features into launchpad:master.
Commit message:
Fix the case when `SnapBase.feature` is `None`
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~andrey-fedoseev/launchpad/+git/launchpad/+merge/431181
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~andrey-fedoseev/launchpad:snap-base-features into launchpad:master.
diff --git a/lib/lp/snappy/model/snapbase.py b/lib/lp/snappy/model/snapbase.py
index b6e8b33..a67159b 100644
--- a/lib/lp/snappy/model/snapbase.py
+++ b/lib/lp/snappy/model/snapbase.py
@@ -74,7 +74,7 @@ class SnapBase(Storm):
is_default = Bool(name="is_default", allow_none=False)
- _features = PgJSON(name="features", allow_none=False)
+ _features = PgJSON(name="features", allow_none=True)
def __init__(
self,
@@ -98,6 +98,8 @@ class SnapBase(Storm):
@property
def features(self) -> Dict[Item, bool]:
+ if self._features is None:
+ return {}
features = {}
for token, is_enabled in self._features.items():
try:
diff --git a/lib/lp/snappy/tests/test_snapbase.py b/lib/lp/snappy/tests/test_snapbase.py
index 978e8b6..e7cd522 100644
--- a/lib/lp/snappy/tests/test_snapbase.py
+++ b/lib/lp/snappy/tests/test_snapbase.py
@@ -93,6 +93,11 @@ class TestSnapBase(TestCaseWithFactory):
snap_base.features,
)
+ def test_blank_features(self):
+ snap_base = self.factory.makeSnapBase(name="foo")
+ removeSecurityProxy(snap_base)._features = None
+ self.assertEqual({}, snap_base.features)
+
class TestSnapBaseProcessors(TestCaseWithFactory):
Follow ups