Example #1
0
 def test_clean_file_upload_form_multiple(self):
     kwargs = {'next_view': 'Launch Stack'}
     t = forms.TemplateForm({}, **kwargs)
     precleaned = {
         'template_url': 'http://templateurl.com',
         'template_data': 'http://templateurl.com',
     }
     self.assertRaises(exceptions.ValidationError, t.clean_uploaded_files,
                       'template', 'template', precleaned, {})
Example #2
0
    def test_clean_file_upload_form_url(self):
        kwargs = {'next_view': 'Launch Stack'}
        t = forms.TemplateForm({}, **kwargs)
        precleaned = {
            'template_url': 'http://templateurl.com',
        }
        t.clean_uploaded_files('template', 'template', precleaned, {})

        self.assertEqual(precleaned['template_url'], 'http://templateurl.com')
Example #3
0
    def test_clean_file_upload_form_invalid_json(self):
        kwargs = {'next_view': 'Launch Stack'}
        t = forms.TemplateForm({}, **kwargs)
        precleaned = {
            'template_data': 'http://templateurl.com',
        }
        json_str = '{notvalidjson::::::json/////json'
        files = {'template_upload': self.SimpleFile('template_name', json_str)}

        self.assertRaises(exceptions.ValidationError, t.clean_uploaded_files,
                          'template', 'template', precleaned, files)
Example #4
0
    def test_clean_file_upload_form_valid_data(self):
        kwargs = {'next_view': 'Launch Stack'}
        t = forms.TemplateForm({}, **kwargs)
        precleaned = {
            'template_data': 'http://templateurl.com',
        }

        json_str = '{"isvalid":"json"}'
        files = {'template_upload': self.SimpleFile('template_name', json_str)}

        t.clean_uploaded_files('template', 'template', precleaned, files)
        self.assertEqual(json_str, precleaned['template_data'])