blob: ea8738e18656ebb42d550b1f72ff1e1025e39db4 [file] [log] [blame]
Matteo Scandolo23cf15f2018-03-06 18:12:36 -08001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17import unittest
18from xosgenx.jinja2_extensions.django import *
19
20class Jinja2BaseTests(unittest.TestCase):
21 def test_xproto_optioned_fields_to_list(self):
22
23 fields = [
24 {
25 'name': 'has_feedback_1',
26 'options': {
27 'feedback_state': 'True',
28 }
29 },
30 {
31 'name': 'has_feedback_2',
32 'options': {
33 'feedback_state': 'True',
34 }
35 },
36 {
37 'name': 'no_feedback',
38 'options': {
39 'feedback_state': 'False',
40 }
41 }
42 ]
43
44 res = xproto_optioned_fields_to_list(fields, 'feedback_state', 'True')
45 self.assertEqual(res, ["has_feedback_1", "has_feedback_2"])
46
47if __name__ == '__main__':
48 unittest.main()
49
50