def test_reload_answer_access(self):
     AnswerAccessDefinition.objects.all().delete()
     self.assertEquals(AnswerAccessDefinition.objects.count(), 0)
     AnswerAccessDefinition.reload_answer_categories()
     self.assertTrue(AnswerAccessDefinition.objects.count() > 0)
     # chech for each access type has an entry
     channels = [USSDAccess.choice_name(), ODKAccess.choice_name(), WebAccess.choice_name()]
     allowed_channels = AnswerAccessDefinition.objects.values_list('channel', flat=True)
     for channel in channels:
         self.assertIn(channel, allowed_channels)
         self.assertTrue(len(AnswerAccessDefinition.answer_types(channel)) > 0)
     answer_types = Answer.answer_types()
     for answer_type in [VideoAnswer, AudioAnswer, ImageAnswer]:
         self.assertNotIn(answer_type.choice_name(), AnswerAccessDefinition.answer_types(USSDAccess.choice_name()))
 def __init__(self, *args, **kwargs):
     super(TemplateForm, self).__init__(*args, **kwargs)
     instance = kwargs.get('instance', None)
     if instance:
         self.help_text = ' and '.join(
             AnswerAccessDefinition.access_channels(
                 instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.fields['answer_type'].choices = [
         (name, name) for name in AnswerAccessDefinition.answer_types(
             USSDAccess.choice_name())
         if name != AutoResponse.choice_name()
     ]
     self.fields['answer_type'].choices.insert(
         0, ('', '----Select Answer Type -----'))
     # key,val pair of supported access channels for each answer type
     self.answer_map = {}
     # not much needed since we are only restricting to USSD access
     definitions = AnswerAccessDefinition.objects.filter()
     for definiton in definitions:
         self.answer_map[definiton.answer_type] = self.answer_map.get(
             definiton.answer_type, [])
         self.answer_map[definiton.answer_type].append(
             definiton.channel)
     self.order_fields(['module', 'identifier', 'text', 'answer_type'])
示例#3
0
 def test_reload_answer_access(self):
     AnswerAccessDefinition.objects.all().delete()
     self.assertEquals(AnswerAccessDefinition.objects.count(), 0)
     AnswerAccessDefinition.reload_answer_categories()
     self.assertTrue(AnswerAccessDefinition.objects.count() > 0)
     # chech for each access type has an entry
     channels = [
         USSDAccess.choice_name(),
         ODKAccess.choice_name(),
         WebAccess.choice_name()
     ]
     allowed_channels = AnswerAccessDefinition.objects.values_list(
         'channel', flat=True)
     for channel in channels:
         self.assertIn(channel, allowed_channels)
         self.assertTrue(
             len(AnswerAccessDefinition.answer_types(channel)) > 0)
     answer_types = Answer.answer_types()
     for answer_type in [VideoAnswer, AudioAnswer, ImageAnswer]:
         self.assertNotIn(
             answer_type.choice_name(),
             AnswerAccessDefinition.answer_types(USSDAccess.choice_name()))
示例#4
0
 def __init__(self, *args, **kwargs):
     super(TemplateForm, self).__init__(*args, **kwargs)
     instance = kwargs.get('instance', None)
     if instance:
         self.help_text = ' and '.join(
             AnswerAccessDefinition.access_channels(
                 instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.fields['answer_type'].choices = [(name, name) for name in
                                           AnswerAccessDefinition.answer_types(USSDAccess.choice_name())
                                           if name != AutoResponse.choice_name()]
     self.fields['answer_type'].choices.insert(0,('','----Select Answer Type -----'))
     # key,val pair of supported access channels for each answer type
     self.answer_map = {}
     # not much needed since we are only restricting to USSD access
     definitions = AnswerAccessDefinition.objects.filter()
     for definiton in definitions:
         self.answer_map[definiton.answer_type] = self.answer_map.get(
             definiton.answer_type, [])
         self.answer_map[definiton.answer_type].append(
             definiton.channel)
     self.order_fields(['module', 'identifier', 'text', 'answer_type'])