- Timestamp:
- 14 Mar 2012, 17:18:39 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/widgets
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/widgets/phonewidget.py
r7874 r7883 127 127 _("Phone numbers may contain numbers only."), 128 128 ValueError('non numbers in phone number')) 129 if result in ('--', '', None): 129 # We consider also values ending with '--' as missing values. 130 # This means that any prefix setting in the form will switch 131 # back to default upon submit if no further phone fields are filled. 132 # As advantage we get only valid phone numbers or missing value. 133 if result in ('', None) or result.endswith('--'): 130 134 result = self.context.missing_value 131 135 return result -
main/waeup.kofa/trunk/src/waeup/kofa/widgets/tests/test_phonewidget.py
r7874 r7883 143 143 self.assertEqual(content.baz, None) 144 144 return 145 146 def test_partial_values(self): 147 content = SampleContent() 148 request = TestRequest() 149 150 request.form['form.foo.country'] = u'+123' 151 request.form['form.foo.area'] = u'456' 152 request.form['form.foo.ext'] = u'' 153 request.form['form.bar.country'] = u'+123' 154 request.form['form.bar.area'] = u'' 155 request.form['form.bar.ext'] = u'789' 156 request.form['form.baz.country'] = u'+123' 157 request.form['form.baz.area'] = u'456' 158 request.form['form.baz.ext'] = u'789' 159 request.form['form.actions.apply'] = u'' 160 161 SampleForm(content, request)() 162 163 # check new values in object 164 self.assertEqual(content.foo, None) 165 self.assertEqual(content.bar, 'bar') # input error, no value was set 166 self.assertEqual(content.baz, None) 167 return 168 169 def test_no_values(self): 170 # if the last two subfields contain no value, no phone will be set 171 content = SampleContent() 172 request = TestRequest() 173 174 request.form['form.bar.country'] = u'+123' 175 request.form['form.bar.area'] = u'' 176 request.form['form.bar.ext'] = u'' 177 request.form['form.baz.country'] = u'+124' 178 request.form['form.baz.area'] = u'' 179 request.form['form.baz.ext'] = u'' 180 request.form['form.actions.apply'] = u'' 181 182 SampleForm(content, request)() 183 184 # check new values in object 185 self.assertEqual(content.bar, u'') # default missing value 186 self.assertEqual(content.baz, None) 187 return
Note: See TracChangeset for help on using the changeset viewer.