~michael.nelson/ubuntu-webcatalog/rt-61147-nagios-sca-import

« back to all changes in this revision

Viewing changes to src/webcatalog/tests/test_forms.py

[r=beuno] Invalid desktop files are handled (skipped) rather than erroring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from __future__ import absolute_import
21
21
 
 
22
import os
 
23
 
22
24
from django.forms import ValidationError
23
25
from django.test import TestCase
24
26
 
108
110
        self.assertTrue(form.is_valid())
109
111
        self.assertEqual('MyPkg description', form.cleaned_data['description'])
110
112
 
 
113
    def test_get_form_from_desktop_data_bad_data(self):
 
114
        """Don't panic if we can't parse the desktop file."""
 
115
        app = self.factory.make_application(package_name='workrave')
 
116
        curdir = os.path.dirname(__file__)
 
117
        desktop_file_path = os.path.join(curdir, 'test_data',
 
118
                                         'workrave:workrave.desktop')
 
119
        with open(desktop_file_path, 'r') as desktop_file:
 
120
            data = desktop_file.read()
 
121
 
 
122
        form = ArchiveApplicationForm.get_form_from_desktop_data(
 
123
            data, distroseries=app.distroseries)
 
124
 
 
125
        self.assertFalse(form.is_valid())
 
126
 
111
127
    def test_extra_fields(self):
112
128
        # There are a bunch of extra fields which are also supported by
113
129
        # the model form.