[CORD-2810] Only synchronizers can write feedback state

Change-Id: Ia3f28763a0212a570186e4c6c5cb118c40325b5b
diff --git a/lib/xos-genx/xos-genx-tests/test_django_generator.py b/lib/xos-genx/xos-genx-tests/test_django_generator.py
index 0ba90b5..c3ffef5 100644
--- a/lib/xos-genx/xos-genx-tests/test_django_generator.py
+++ b/lib/xos-genx/xos-genx-tests/test_django_generator.py
@@ -73,6 +73,32 @@
         self.assertEqual(len(blank_true), 1)
         self.assertEqual(len(blank_false), 1)
 
+    def test_feedback_state(self):
+        """
+        [XOS-GenX] Generate DJANGO models, verify feedback_state fields
+        """
+        xproto = \
+            """
+            option app_label = "test";
+
+            message ParentFoo {
+                required string parent_name = 1 [null = False, blank = False, feedback_state = True];
+            }
+
+            message Foo (ParentFoo) {
+                required string name = 1 [null = False, blank = False, feedback_state = True];
+            }
+            """
+
+        args = FakeArgs()
+        args.inputs = xproto
+        args.target = 'django.xtarget'
+        output = XOSProcessor.process(args)
+
+        print output
+
+        self.assertIn("feedback_state_fields = ['parent_name', 'name']", output)
+
 if __name__ == '__main__':
     unittest.main()
 
diff --git a/lib/xos-genx/xos-genx-tests/test_jinja2_django.py b/lib/xos-genx/xos-genx-tests/test_jinja2_django.py
new file mode 100644
index 0000000..ea8738e
--- /dev/null
+++ b/lib/xos-genx/xos-genx-tests/test_jinja2_django.py
@@ -0,0 +1,50 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import unittest
+from xosgenx.jinja2_extensions.django import *
+
+class Jinja2BaseTests(unittest.TestCase):
+    def test_xproto_optioned_fields_to_list(self):
+
+        fields = [
+            {
+                'name': 'has_feedback_1',
+                'options': {
+                    'feedback_state': 'True',
+                }
+            },
+            {
+                'name': 'has_feedback_2',
+                'options': {
+                    'feedback_state': 'True',
+                }
+            },
+            {
+                'name': 'no_feedback',
+                'options': {
+                    'feedback_state': 'False',
+                }
+            }
+        ]
+
+        res = xproto_optioned_fields_to_list(fields, 'feedback_state', 'True')
+        self.assertEqual(res, ["has_feedback_1", "has_feedback_2"])
+
+if __name__ == '__main__':
+    unittest.main()
+
+
diff --git a/lib/xos-genx/xos-genx-tests/test_translator.py b/lib/xos-genx/xos-genx-tests/test_translator.py
index 2f8cc8a..5923bc7 100644
--- a/lib/xos-genx/xos-genx-tests/test_translator.py
+++ b/lib/xos-genx/xos-genx-tests/test_translator.py
@@ -315,6 +315,28 @@
         output = XOSProcessor.process(args)
         self.assertIn('verbose_name: "Verbose Foo Name"', output)
 
+    def test_feedback_field(self):
+        xproto = \
+"""
+option app_label = "test";
+
+message ParentFoo {
+    required string parent_name = 1 [null = False, blank = False, feedback_state = True];
+}
+
+message Foo (ParentFoo) {
+    required string name = 1 [null = False, blank = False, feedback_state = True];
+}
+"""
+
+        args = FakeArgs()
+        args.inputs = xproto
+        args.target = 'modeldefs.xtarget'
+        output = XOSProcessor.process(args)
+
+        read_only = filter(lambda s: 'read_only: True' in s, output.splitlines())
+        self.assertEqual(len(read_only), 3) # readonly is 1 for ParentFoo and 2 for Foo
+
 if __name__ == '__main__':
     unittest.main()