Exemplo n.º 1
0
    def test_overview_lists_nested_services_sorted_as_table(self, browser):
        sub_folder = create(Builder('folder').within(self.folder))

        create(
            Builder('egov service').titled(u'B Leistung').within(
                sub_folder).having(orgunit=self.to_reference,
                                   modificationDate=self.modification_date))

        browser.login().visit(self.folder, view='egovleistung_overview')

        self.assertEquals(
            [['Title', 'OrgUnit', 'Modified'],
             [
                 'A Leistung', u'B\xe4m',
                 readable_date_time_text(None, self.modification_date)
             ],
             [
                 'B Leistung', u'B\xe4m',
                 readable_date_time_text(None, self.modification_date)
             ],
             [
                 'Z Leistung', u'B\xe4m',
                 readable_date_time_text(None, self.modification_date)
             ]],
            browser.css('table.listing').first.lists())
Exemplo n.º 2
0
    def test_overview_lists_services_sorted_as_table(self, browser):

        browser.login().visit(self.folder, view='egovleistung_overview')

        self.assertEquals(
            [['Title', 'OrgUnit', 'Modified'],
             [
                 'A Leistung', u'B\xe4m',
                 readable_date_time_text(None, self.modification_date)
             ],
             [
                 'Z Leistung', u'B\xe4m',
                 readable_date_time_text(None, self.modification_date)
             ]],
            browser.css('table.listing').first.lists())
 def test_if_date_is_today_return_it_as_string(self):
     time_today = time(21, 8)
     self.assertEqual(
         'heute, 21:08',
         readable_date_time_text(
             object,
             datetime.combine(datetime.now(), time_today)))
Exemplo n.º 4
0
 def test_if_date_is_today_return_it_as_string(self):
     time_today = time(21, 8)
     self.assertEqual(
         'heute, 21:08',
         readable_date_time_text(
             object,
             datetime.combine(datetime.now(), time_today)))
 def test_if_date_is_yesterday_return_it_as_string(self):
     date_yesterday = (datetime.now() - timedelta(1)).date()
     time_yesterday = time(20, 8)
     self.assertEqual(
         'gestern, 20:08',
         readable_date_time_text(
             object, datetime.combine(date_yesterday, time_yesterday)))
Exemplo n.º 6
0
    def _helper(item, value):
        if field is None:
            return ''

        obj = item.getObject()

        if isdate:
            raw_date = obj.get_header(field)
            raw_date = re.sub(r'\((.*)\)', '\g<1>', raw_date)
            try:
                date = DateTime(raw_date)
            except SyntaxError:
                return ''
            return helper.readable_date_time_text(item, date)

        elif field == 'attachments':
            imgpath = '++resource++attachment.png'
            return '<img src="%s" alt="%s" /> %s' % (
                imgpath,
                translate(_(u'attachment_icon_alt_text',
                           default=u'Attachment'),
                          context=obj.REQUEST),
                len(obj.attachment_infos))

        else:
            return obj.get_header(field)
 def test_if_date_is_yesterday_return_it_as_string(self):
     date_yesterday = (datetime.now() - timedelta(1)).date()
     time_yesterday = time(20, 8)
     self.assertEqual(
         'gestern, 20:08',
         readable_date_time_text(
             object,
             datetime.combine(date_yesterday, time_yesterday)))
Exemplo n.º 8
0
    def test_overview_lists_services_does_not_break_if_orgunit_is_deleted(
            self, browser):

        self.to_reference.aq_parent.manage_delObjects(
            ids=[self.to_reference.id])
        transaction.commit()

        browser.login().visit(self.folder, view='egovleistung_overview')

        self.assertEquals(
            [['Title', 'OrgUnit', 'Modified'],
             [
                 'A Leistung', u'',
                 readable_date_time_text(None, self.modification_date)
             ],
             [
                 'Z Leistung', u'',
                 readable_date_time_text(None, self.modification_date)
             ]],
            browser.css('table.listing').first.lists())
Exemplo n.º 9
0
    def _helper(item, value):
        if field is None:
            return ''

        obj = item.getObject()

        if isdate:
            date = obj.get_header(field, isdate)
            return helper.readable_date_time_text(item, date)

        elif field == 'attachments':
            imgpath = '++resource++attachment.png'
            return '<img src="%s" alt="%s" /> %s' % (
                imgpath,
                translate(_(u'attachment_icon_alt_text',
                            default=u'Attachment'),
                          context=obj.REQUEST),
                len(obj.attachment_infos))

        else:
            return obj.get_header(field)
 def test_if_date_is_older_than_yesterday_return_it_as_date(self):
     self.assertEqual(
         '17.10.2012 20:08',
         readable_date_time_text(object, datetime(2012, 10, 17, 20, 8)))
 def test_none_if_value_is_invalid(self):
     self.assertEqual(
         None,
         readable_date_time_text(object, 'invalid date'))
 def test_none_if_no_value_is_given(self):
     self.assertEqual(
         None,
         readable_date_time_text(object, None))
Exemplo n.º 13
0
 def test_if_date_is_older_than_yesterday_return_it_as_date(self):
     self.assertEqual(
         '17.10.2012 20:08',
         readable_date_time_text(object, datetime(2012, 10, 17, 20, 8)))
Exemplo n.º 14
0
 def test_none_if_value_is_invalid(self):
     self.assertEqual(
         None,
         readable_date_time_text(object, 'invalid date'))
Exemplo n.º 15
0
 def test_none_if_no_value_is_given(self):
     self.assertEqual(
         None,
         readable_date_time_text(object, None))