예제 #1
0
 def test_global_vars_validation(self):
     template = 'Hello {name} - you have completed {count} forms today!'
     # if 0 or 1 are defined it should fail
     with self.assertRaises(InvalidParameterException):
         PerformanceConfiguration(template=template).validate()
     with self.assertRaises(InvalidParameterException):
         PerformanceConfiguration(template=template, template_variables=[
             TemplateVariable(slug='name', type='form'),
         ]).validate()
     # if both are defined it should not succeed
     PerformanceConfiguration(template=template, template_variables=[
         TemplateVariable(slug='name', type='form'),
         TemplateVariable(slug='count', type='form'),
     ]).validate()
예제 #2
0
def _make_performance_config(domain, interval, hour=DEFAULT_HOUR, day_of_week=DEFAULT_WEEK_DAY,
                             day_of_month=DEFAULT_MONTH_DAY):
    config = PerformanceConfiguration(
        domain=domain,
        recipient_id=uuid.uuid4().hex,
        template='test',
        schedule=ScheduleConfiguration(
            interval=interval,
            hour=hour,
            day_of_week=day_of_week,
            day_of_month=day_of_month,
        )
    )
    config.save()
    return config
예제 #3
0
 def test_validate_bad_formats(self):
     invalid_test_cases = [
         None,
         '',
         'too.many.periods',
         'bad.namespace',
         ' prewhitespace',
         'postwhitespace ',
         'inner whitespace',
     ]
     for invalid in invalid_test_cases:
         with self.assertRaises(InvalidParameterException):
             parse_param(invalid)
         if invalid:
             with self.assertRaises(InvalidParameterException):
                 template = 'Hello {%s}' % invalid
                 PerformanceConfiguration(template=template).validate()
예제 #4
0
 def performance_config(self):
     return PerformanceConfiguration(domain=self.domain)
예제 #5
0
def _make_performance_config(domain):
    config = PerformanceConfiguration(domain=domain,
                                      recipient_id=uuid.uuid4().hex,
                                      template='test')
    config.save()
    return config