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()
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
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()
def performance_config(self): return PerformanceConfiguration(domain=self.domain)
def _make_performance_config(domain): config = PerformanceConfiguration(domain=domain, recipient_id=uuid.uuid4().hex, template='test') config.save() return config