Exemple #1
0
 def test_format_copy_override(self):
     dp_input1 = BasePickerInput(
         format='%Y-%m-%d').start_of('format_copy_override')
     dp_input2 = BasePickerInput(
         format='%m/%d/%Y').end_of('format_copy_override')
     self.assertEqual(dp_input1.format, '%Y-%m-%d')
     self.assertEqual(dp_input2.format, '%m/%d/%Y')
 def test_format_copy_override(self):
     dp_input1 = BasePickerInput(
         format="%Y-%m-%d").start_of("format_copy_override")
     dp_input2 = BasePickerInput(
         format="%m/%d/%Y").end_of("format_copy_override")
     self.assertEqual(dp_input1.format, "%Y-%m-%d")
     self.assertEqual(dp_input2.format, "%m/%d/%Y")
Exemple #3
0
    def __init__(self, attrs=None, format=None, options={}):
        if settings.USE_I18N:
            options["locale"] = get_user_locale_lazy()
        if settings.USE_L10N:
            # ignore the 'format' option
            options.pop("format", None)
            format = None
            # lazyly load the right format
            self.format = get_user_locale_format_lazy(self.display_format_key)

        # reset options to default 'None' if no change was made above
        if not options:
            options = None
        BasePickerInput.__init__(self,
                                 attrs=attrs,
                                 format=format,
                                 options=options)
Exemple #4
0
 def test_format_py2js(self):
     self.assertEqual(BasePickerInput.format_py2js(
         '%Y-%m-%d'), 'YYYY-MM-DD')
     self.assertEqual(BasePickerInput.format_py2js(
         '%d/%m/%Y'), 'DD/MM/YYYY')
Exemple #5
0
 def _calculate_format(self):
     if settings.USE_L10N:
         # the right format is loaded already in the constructor above
         return self.format
     else:
         return BasePickerInput._calculate_format(self)
 def test_format_as_both(self):
     dp_input = BasePickerInput(format='%m/%d/%Y',
                                options={'format': 'YYYY-MM-DD'})
     self.assertEqual(dp_input.format, '%Y-%m-%d')
 def test_format_as_option(self):
     dp_input = BasePickerInput(options={'format': 'YYYY-MM-DD'})
     self.assertEqual(dp_input.format, '%Y-%m-%d')
 def test_format_as_parameter(self):
     dp_input = BasePickerInput(format='%Y-%m-%d')
     self.assertEqual(dp_input.format, '%Y-%m-%d')
 def test_raising_error_on_no_start_of_key(self):
     endpicker = BasePickerInput()
     self.assertRaises(KeyError, lambda: endpicker.end_of("undefined"))
 def test_format_copy(self):
     dp_input1 = BasePickerInput(format="%Y-%m-%d").start_of("format_copy")
     dp_input2 = BasePickerInput().end_of("format_copy")
     self.assertEqual(dp_input1.format, "%Y-%m-%d")
     self.assertEqual(dp_input2.format, "%Y-%m-%d")
Exemple #11
0
 def test_format_py2js(self):
     self.assertEqual(BasePickerInput.format_py2js("%Y-%m-%d"), "YYYY-MM-DD")
     self.assertEqual(BasePickerInput.format_py2js("%d/%m/%Y"), "DD/MM/YYYY")
 def test_format_as_both(self):
     dp_input = BasePickerInput(format="%m/%d/%Y",
                                options={"format": "YYYY-MM-DD"})
     self.assertEqual(dp_input.format, "%Y-%m-%d")
 def test_format_as_option(self):
     dp_input = BasePickerInput(options={"format": "YYYY-MM-DD"})
     self.assertEqual(dp_input.format, "%Y-%m-%d")
Exemple #14
0
 def test_format_copy(self):
     dp_input1 = BasePickerInput(format='%Y-%m-%d').start_of('format_copy')
     dp_input2 = BasePickerInput().end_of('format_copy')
     self.assertEqual(dp_input1.format, '%Y-%m-%d')
     self.assertEqual(dp_input2.format, '%Y-%m-%d')