def test_vocabulary_to_choice_edit_items_excluded_items(self):
     # Excluded items are not included.
     items = vocabulary_to_choice_edit_items(
         self.ChoiceEnum, include_description=True,
         excluded_items=[self.ChoiceEnum.ITEM_B])
     expected = [self._makeItemDict(self.ChoiceEnum.ITEM_A)]
     self.assertEqual(expected, items)
 def test_vocabulary_to_choice_edit_items_no_description(self):
     # There are no descriptions unless wanted.
     overrides = {'description': ''}
     items = vocabulary_to_choice_edit_items(self.ChoiceEnum)
     expected = [self._makeItemDict(e.value, overrides)
                 for e in self.ChoiceEnum]
     self.assertEqual(expected, items)
 def test_vocabulary_to_choice_edit_items(self):
     # The items list is as expected without the feature flag.
     items = vocabulary_to_choice_edit_items(self.ChoiceEnum)
     overrides = {'description': ''}
     expected = [self._makeItemDict(e.value, overrides)
                 for e in self.ChoiceEnum]
     self.assertEqual(expected, items)
Esempio n. 4
0
 def test_vocabulary_to_choice_edit_items_excluded_items(self):
     # Excluded items are not included.
     items = vocabulary_to_choice_edit_items(
         self.ChoiceEnum,
         include_description=True,
         excluded_items=[self.ChoiceEnum.ITEM_B])
     expected = [self._makeItemDict(self.ChoiceEnum.ITEM_A)]
     self.assertEqual(expected, items)
Esempio n. 5
0
 def test_vocabulary_to_choice_edit_items_no_description(self):
     # There are no descriptions unless wanted.
     overrides = {'description': ''}
     items = vocabulary_to_choice_edit_items(self.ChoiceEnum)
     expected = [
         self._makeItemDict(e.value, overrides) for e in self.ChoiceEnum
     ]
     self.assertEqual(expected, items)
Esempio n. 6
0
 def test_vocabulary_to_choice_edit_items(self):
     # The items list is as expected without the feature flag.
     items = vocabulary_to_choice_edit_items(self.ChoiceEnum)
     overrides = {'description': ''}
     expected = [
         self._makeItemDict(e.value, overrides) for e in self.ChoiceEnum
     ]
     self.assertEqual(expected, items)
 def generateChoiceConfForEntry(self, entry):
     disabled_items = [
         item.value for item in RosettaImportStatus
         if not entry.canSetStatus(item.value, self.user)
     ]
     items = vocabulary_to_choice_edit_items(
         RosettaImportStatus,
         disabled_items=disabled_items,
         css_class_prefix='translationimportstatus')
     return {'value': entry.status.title, 'items': items}
 def test_view_data_model(self):
     # The view's json request cache contains the expected data.
     view = create_initialized_view(self.project_group, '+index')
     cache = IJSONRequestCache(view.request)
     policy_items = [(item.name, item) for item in EXCLUSIVE_TEAM_POLICY]
     team_membership_policy_data = vocabulary_to_choice_edit_items(
         SimpleVocabulary.fromItems(policy_items),
         value_fn=lambda item: item.name)
     self.assertContentEqual(team_membership_policy_data,
                             cache.objects['team_membership_policy_data'])
 def generateChoiceConfForEntry(self, entry):
     disabled_items = [
         item.value for item in RosettaImportStatus
                    if not entry.canSetStatus(item.value, self.user)]
     items = vocabulary_to_choice_edit_items(
             RosettaImportStatus, disabled_items=disabled_items,
             css_class_prefix='translationimportstatus')
     return {
         'value': entry.status.title,
         'items': items}
Esempio n. 10
0
 def initialize(self):
     # Insert close team membership policy data into the json cache.
     # This data is used for the maintainer and driver pickers.
     super(PillarViewMixin, self).initialize()
     cache = IJSONRequestCache(self.request)
     policy_items = [(item.name, item) for item in EXCLUSIVE_TEAM_POLICY]
     team_membership_policy_data = vocabulary_to_choice_edit_items(
         SimpleVocabulary.fromItems(policy_items),
         value_fn=lambda item: item.name)
     cache.objects['team_membership_policy_data'] = (
         team_membership_policy_data)
Esempio n. 11
0
 def test_view_data_model(self):
     # The view's json request cache contains the expected data.
     view = create_initialized_view(self.product, '+index')
     cache = IJSONRequestCache(view.request)
     policy_items = [(item.name, item) for item in EXCLUSIVE_TEAM_POLICY]
     team_membership_policy_data = vocabulary_to_choice_edit_items(
         SimpleVocabulary.fromItems(policy_items),
         value_fn=lambda item: item.name)
     self.assertContentEqual(
         team_membership_policy_data,
         cache.objects['team_membership_policy_data'])
Esempio n. 12
0
 def initialize(self):
     # Insert close team membership policy data into the json cache.
     # This data is used for the maintainer and driver pickers.
     super(PillarViewMixin, self).initialize()
     cache = IJSONRequestCache(self.request)
     policy_items = [(item.name, item) for item in EXCLUSIVE_TEAM_POLICY]
     team_membership_policy_data = vocabulary_to_choice_edit_items(
         SimpleVocabulary.fromItems(policy_items),
         value_fn=lambda item: item.name)
     cache.objects['team_membership_policy_data'] = (
         team_membership_policy_data)
Esempio n. 13
0
 def test_vocabulary_to_choice_edit_items_with_description(self):
     # The items list is as expected.
     items = vocabulary_to_choice_edit_items(self.ChoiceEnum,
                                             include_description=True)
     expected = [self._makeItemDict(e.value) for e in self.ChoiceEnum]
     self.assertEqual(expected, items)
 def test_vocabulary_to_choice_edit_items_with_description(self):
     # The items list is as expected.
     items = vocabulary_to_choice_edit_items(
         self.ChoiceEnum, include_description=True)
     expected = [self._makeItemDict(e.value) for e in self.ChoiceEnum]
     self.assertEqual(expected, items)