[Mailman-checkins] [Git][mailman/mailman][coverage] Boost coverage.

2017-07-24 Thread Barry Warsaw via Mailman-checkins
Barry Warsaw pushed to branch coverage at mailman / Mailman Core


Commits:
8fbcf37a by Barry Warsaw at 2017-07-24T19:54:48-04:00
Boost coverage.

- - - - -


2 changed files:

- src/mailman/rest/listconf.py
- src/mailman/rest/preferences.py


Changes:

=
src/mailman/rest/listconf.py
=
--- a/src/mailman/rest/listconf.py
+++ b/src/mailman/rest/listconf.py
@@ -97,7 +97,7 @@ def pipeline_validator(pipeline_name):
 
 
 def password_bytes_validator(value):
-if value is None or isinstance(value, bytes):
+if value is None or isinstance(value, bytes):   # pragma: nobranch
 return value
 return config.password_context.encrypt(value).encode('utf-8')
 
@@ -196,7 +196,7 @@ def api_attributes(api):
 # attributes, although we map them to templates.  In API 3.1 and beyond,
 # only the template manager API can be used for these.
 attributes = ATTRIBUTES.copy()
-if api.version_info == (3, 0):
+if api.version_info == (3, 0):  # pragma: nobranch
 attributes.update({
 attribute: URIAttributeMapper(str)
 for attribute in TEMPLATE_ATTRIBUTES
@@ -243,7 +243,7 @@ class ListConfiguration:
 # handled by the template manager API.
 validators = VALIDATORS.copy()
 attributes = api_attributes(self.api)
-if self.api.version_info == (3, 0):
+if self.api.version_info == (3, 0): # pragma: nobranch
 validators.update({
 attribute: URIAttributeMapper(str)
 for attribute in TEMPLATE_ATTRIBUTES


=
src/mailman/rest/preferences.py
=
--- a/src/mailman/rest/preferences.py
+++ b/src/mailman/rest/preferences.py
@@ -69,9 +69,7 @@ class Preferences(ReadOnlyPreferences):
 """Preferences which can be changed."""
 
 def _patch_put(self, request, response, is_optional):
-if self._parent is None:
-not_found(response)
-return
+assert self._parent is not None
 kws = dict(
 acknowledge_posts=GetterSetter(as_boolean),
 hide_address=GetterSetter(as_boolean),



View it on GitLab: 
https://gitlab.com/mailman/mailman/commit/8fbcf37a3d9837799f3bb18e5e4395caf60bf44f

---
View it on GitLab: 
https://gitlab.com/mailman/mailman/commit/8fbcf37a3d9837799f3bb18e5e4395caf60bf44f
You're receiving this email because of your account on gitlab.com.
___
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org



[Mailman-checkins] [Git][mailman/mailman][coverage] Boost coverage.

2017-07-24 Thread Barry Warsaw via Mailman-checkins
Barry Warsaw pushed to branch coverage at mailman / Mailman Core


Commits:
f9cfbb32 by Barry Warsaw at 2017-07-24T14:44:41-04:00
Boost coverage.

- - - - -


1 changed file:

- src/mailman/rest/tests/test_header_matches.py


Changes:

=
src/mailman/rest/tests/test_header_matches.py
=
--- a/src/mailman/rest/tests/test_header_matches.py
+++ b/src/mailman/rest/tests/test_header_matches.py
@@ -51,6 +51,17 @@ class TestHeaderMatches(unittest.TestCase):
 self.assertEqual(cm.exception.reason,
  'No header match at this position: 0')
 
+def test_patch_put_missing_header_match(self):
+with self.assertRaises(HTTPError) as cm:
+call_api('http://localhost:9001/3.0/lists/ant.example.com'
+ '/header-matches/0', dict(
+ header='From',
+ ),
+ method='PATCH')
+self.assertEqual(cm.exception.code, 404)
+self.assertEqual(cm.exception.reason,
+ 'No header match at this position: 0')
+
 def test_add_duplicate(self):
 header_matches = IHeaderMatchList(self._mlist)
 with transaction():
@@ -70,3 +81,30 @@ class TestHeaderMatches(unittest.TestCase):
 call_api('http://localhost:9001/3.0/lists/bee.example.com'
  '/header-matches/')
 self.assertEqual(cm.exception.code, 404)
+
+def test_header_match_post_bad_action(self):
+header_matches = IHeaderMatchList(self._mlist)
+with transaction():
+header_matches.append('header', 'pattern')
+with self.assertRaises(HTTPError) as cm:
+call_api('http://localhost:9001/3.0/lists/ant.example.com'
+ '/header-matches', {
+ 'action': 'donothing',
+})
+self.assertEqual(cm.exception.code, 400)
+self.assertEqual(cm.exception.reason,
+ 'Cannot convert parameters: action')
+
+def test_header_match_patch_bad_action(self):
+header_matches = IHeaderMatchList(self._mlist)
+with transaction():
+header_matches.append('header', 'pattern')
+with self.assertRaises(HTTPError) as cm:
+call_api('http://localhost:9001/3.0/lists/ant.example.com'
+ '/header-matches/0', {
+ 'action': 'donothing',
+},
+ method='PATCH')
+self.assertEqual(cm.exception.code, 400)
+self.assertEqual(cm.exception.reason,
+ 'Cannot convert parameters: action')



View it on GitLab: 
https://gitlab.com/mailman/mailman/commit/f9cfbb32144d328aa5a662fb192153616f0cbbf7

---
View it on GitLab: 
https://gitlab.com/mailman/mailman/commit/f9cfbb32144d328aa5a662fb192153616f0cbbf7
You're receiving this email because of your account on gitlab.com.
___
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org