def test_context_manager(self, values):
        values_generator = mock.Mock(return_value=values)
        initial_values = self.block.fields['field'].values

        with FieldValuesContextManager(self.block, 'field', values_generator):
            available_values = self.block.fields['field'].values

            self.assertTrue(values_generator.called)
            self.assertEqual(available_values, values)

        self.assertEqual(self.block.fields['field'].values, initial_values)
Beispiel #2
0
 def studio_view(self, context):
     # can't use values_provider as we need it to be bound to current block instance
     with FieldValuesContextManager(self, 'question_id',
                                    self.question_ids_values_provider):
         return super(GroupProjectBaseFeedbackDisplayXBlock,
                      self).studio_view(context)