diff options
author | mnandri <mnandri@eumguccion.corporate.thoughtworks.com> | 2015-12-15 18:05:43 +0100 |
---|---|---|
committer | mnandri <mnandri@eunglick.corporate.thoughtworks.com> | 2015-12-18 11:22:34 +0100 |
commit | f8ac23150f5f840eaa4ef920b003966f911de8fa (patch) | |
tree | bf8179d942a0f0e7cc5017a243dded302212b9ed | |
parent | 93350f99193b78c6adf0b79b8565fe477912fd80 (diff) |
enabling backend for Attachment feature toggle
Issue #548
-rw-r--r-- | service/pixelated/resources/features_resource.py | 15 | ||||
-rw-r--r-- | service/test/unit/resources/test_features_resource.py | 41 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/attachment.spec.js | 3 |
3 files changed, 54 insertions, 5 deletions
diff --git a/service/pixelated/resources/features_resource.py b/service/pixelated/resources/features_resource.py index 927cd9e9..2c1d5b1b 100644 --- a/service/pixelated/resources/features_resource.py +++ b/service/pixelated/resources/features_resource.py @@ -20,7 +20,6 @@ from twisted.web.resource import Resource class FeaturesResource(Resource): - DISABLED_FEATURES = ['draftReply'] isLeaf = True def render_GET(self, request): @@ -29,8 +28,14 @@ class FeaturesResource(Resource): if os.environ.get('DISPATCHER_LOGOUT_URL'): dispatcher_features['logout'] = os.environ.get('DISPATCHER_LOGOUT_URL') - if os.environ.get('FEEDBACK_URL') is None: - self.DISABLED_FEATURES.append('feedback') - + disabled_features = self._disabled_features() return respond_json( - {'disabled_features': self.DISABLED_FEATURES, 'dispatcher_features': dispatcher_features}, request) + {'disabled_features': disabled_features, 'dispatcher_features': dispatcher_features}, request) + + def _disabled_features(self): + disabled_features = ['draftReply'] + if os.environ.get('FEEDBACK_URL') is None: + disabled_features.append('feedback') + if 'ATTACHMENT' not in os.environ: + disabled_features.append('attachment') + return disabled_features diff --git a/service/test/unit/resources/test_features_resource.py b/service/test/unit/resources/test_features_resource.py new file mode 100644 index 00000000..bcfad94c --- /dev/null +++ b/service/test/unit/resources/test_features_resource.py @@ -0,0 +1,41 @@ +import json +import os +import unittest + +from mock import patch +from mockito import mock, when, verify +from twisted.internet import defer +from twisted.web.test.requesthelper import DummyRequest + +from pixelated.resources.attachments_resource import AttachmentsResource +from pixelated.resources.features_resource import FeaturesResource +from test.unit.resources import DummySite + + +class FeatureResourceTest(unittest.TestCase): + + def setUp(self): + self.feature_resource = FeaturesResource() + self.web = DummySite(self.feature_resource) + + def test_attachment_feature_is_disabled(self): + request = DummyRequest(['/features']) + + with patch.dict(os.environ, {}, clear=True): + self.web.get(request) + + self.assertEqual(200, request.code) + + response = json.loads(request.written[0]) + self.assertTrue('attachment' in response['disabled_features']) + + def test_attachment_feature_is_enabled(self): + request = DummyRequest(['/features']) + + with patch.dict(os.environ, {'ATTACHMENT': 'Not empty'}, clear=True): + self.web.get(request) + + self.assertEqual(200, request.code) + + response = json.loads(request.written[0]) + self.assertFalse('attachment' in response['disabled_features']) diff --git a/web-ui/test/spec/mail_view/ui/attachment.spec.js b/web-ui/test/spec/mail_view/ui/attachment.spec.js new file mode 100644 index 00000000..5d14f860 --- /dev/null +++ b/web-ui/test/spec/mail_view/ui/attachment.spec.js @@ -0,0 +1,3 @@ +/** + * Created by mnandri on 12/15/15. + */ |