Exemplo n.º 1
0
def upgrade_1016_to_1017(context):
    # Delete imported guidle events if no classifier is used
    classifier = queryAdapter(EventsSourceGuidle(None), IGuidleClassifier)

    if not classifier:
        catalog = getToolByName(context, 'portal_catalog')
        brains = catalog(object_provides=IExternalEvent.__identifier__)

        for brain in brains:
            event = brain.getObject()
            if catalog(path={"query": event.source},
                       portal_type='seantis.dir.events.sourceguidle'):
                log.info('Deleting %s' % (event.Title()))
                event.aq_parent.manage_delObjects([event.getId()])
Exemplo n.º 2
0
    def test_guidle_import(self):
        xml = """<?xml version="1.0" encoding="UTF-8"?>
<guidle:exportData xmlns:guidle="http://www.guidle.com">
  <guidle:groupSet>
    <guidle:group>
      <guidle:offer id="123">
        <guidle:lastUpdateDate>
          2013-07-26T16:00:43.208+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail>
          <guidle:title>Title</guidle:title>
          <guidle:shortDescription>Description</guidle:shortDescription>
          <guidle:longDescription>Long Descritption</guidle:longDescription>
          <guidle:homepage>http://www.example.ch</guidle:homepage>
          <guidle:images>
            <guidle:image>
              <guidle:url>http://www.example.ch/1.png</guidle:url>
            </guidle:image>
          </guidle:images>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:company>Address</guidle:company>
          <guidle:zip>1234</guidle:zip>
          <guidle:city>City</guidle:city>
          <guidle:country>Country</guidle:country>
          <guidle:latitude>1.0</guidle:latitude>
          <guidle:longitude>2.0</guidle:longitude>
        </guidle:address>
        <guidle:contact>
          <guidle:email>[email protected]</guidle:email>
          <guidle:telephone_1>000 111 22 33</guidle:telephone_1>
          <guidle:company>Company</guidle:company>
        </guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2017-08-25</guidle:startDate>
            <guidle:endDate>2017-09-03</guidle:endDate>
            <guidle:weekdays>
              <guidle:day>Mo</guidle:day>
              <guidle:day>Tu</guidle:day>
            </guidle:weekdays>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
      <guidle:offer id="234">
        <guidle:lastUpdateDate>
          2013-07-26T16:00:43.208+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail>
          <guidle:title>Title</guidle:title>
          <guidle:shortDescription>Description</guidle:shortDescription>
          <guidle:longDescription>Long Descritption</guidle:longDescription>
          <guidle:homepage>http://www.example.ch</guidle:homepage>
          <guidle:images>
            <guidle:image>
              <guidle:url>http://www.example.ch/1.png</guidle:url>
            </guidle:image>
          </guidle:images>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:company>Address</guidle:company>
          <guidle:zip>1234</guidle:zip>
          <guidle:city>City</guidle:city>
          <guidle:country>Country</guidle:country>
        </guidle:address>
        <guidle:contact>
          <guidle:email>[email protected]</guidle:email>
          <guidle:telephone_1>000 111 22 33</guidle:telephone_1>
          <guidle:company>Company</guidle:company>
        </guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2017-08-25</guidle:startDate>
            <guidle:endDate>2017-08-25</guidle:endDate>
            <guidle:startTime>09:15:00</guidle:startTime>
            <guidle:endTime>20:50:00</guidle:endTime>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
      <guidle:offer id="50_1">
        <guidle:lastUpdateDate>
          2014-05-28T11:20:35.736+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail id="345">
          <guidle:title>Issue 50</guidle:title>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:city>City</guidle:city>
        </guidle:address>
        <guidle:contact></guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2014-03-12</guidle:startDate>
            <guidle:endDate>2014-12-31</guidle:endDate>
            <guidle:startTime>00:00:00</guidle:startTime>
            <guidle:endTime>00:00:00</guidle:endTime>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
      <guidle:offer id="50_2">
        <guidle:lastUpdateDate>
          2014-05-28T11:20:35.736+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail id="345">
          <guidle:title>Issue 50 (2)</guidle:title>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:city>City</guidle:city>
        </guidle:address>
        <guidle:contact></guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2014-01-01</guidle:startDate>
            <guidle:endDate>2014-02-14</guidle:endDate>
            <guidle:startTime>07:00:00</guidle:startTime>
            <guidle:endTime>19:00:00</guidle:endTime>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
    </guidle:group>
  </guidle:groupSet>
</guidle:exportData>"""

        context = mock.Mock()
        context.url = 'url'

        source = EventsSourceGuidle(context)
        events = [event for event in source.fetch(xml)]
        self.assertEquals(len(events), 4)

        self.assertEquals(str(events[0]['last_update']),
                          '2013-07-26 16:00:43+02:00')
        self.assertEquals(events[0]['fetch_id'], 'url')
        self.assertEquals(events[0]['id'], '123')
        self.assertEquals(events[0]['source_id'], '123')
        self.assertEquals(events[0]['title'], 'Title')
        self.assertEquals(events[0]['short_description'], 'Description')
        self.assertEquals(events[0]['long_description'], 'Long Descritption')
        self.assertEquals(events[0]['location_url'], 'http://www.example.ch')
        self.assertEquals(events[0]['image'], 'http://www.example.ch/1.png')
        self.assertEquals(events[0]['organizer'], 'Company')
        self.assertEquals(events[0]['locality'], 'Address')
        self.assertEquals(events[0]['zipcode'], '1234')
        self.assertEquals(events[0]['town'], 'City')
        self.assertEquals(events[0]['contact_email'], '*****@*****.**')
        self.assertEquals(events[0]['contact_phone'], '000 111 22 33')
        self.assertEquals(events[0]['latitude'], '1.0')
        self.assertEquals(events[0]['longitude'], '2.0')
        self.assertEquals(events[0]['start'], datetime(2017, 8, 25, 0, 0))
        self.assertEquals(events[0]['end'], datetime(2017, 8, 25, 0, 0))
        self.assertEquals(
            events[0]['recurrence'],
            'RRULE:FREQ=WEEKLY;BYDAY=MO,TU;UNTIL=20170904T0000Z')
        self.assertEquals(events[0]['whole_day'], True)
        self.assertEquals(events[0]['timezone'], 'Europe/Zurich')
        self.assertEquals(events[0]['cat1'], set())
        self.assertEquals(events[0]['cat2'], set(['City']))

        self.assertEquals(str(events[1]['last_update']),
                          '2013-07-26 16:00:43+02:00')
        self.assertEquals(events[1]['fetch_id'], 'url')
        self.assertEquals(events[1]['id'], '234')
        self.assertEquals(events[1]['source_id'], '234')
        self.assertEquals(events[1]['title'], 'Title')
        self.assertEquals(events[1]['short_description'], 'Description')
        self.assertEquals(events[1]['long_description'], 'Long Descritption')
        self.assertEquals(events[1]['location_url'], 'http://www.example.ch')
        self.assertEquals(events[1]['image'], 'http://www.example.ch/1.png')
        self.assertEquals(events[1]['organizer'], 'Company')
        self.assertEquals(events[1]['locality'], 'Address')
        self.assertEquals(events[1]['zipcode'], '1234')
        self.assertEquals(events[1]['town'], 'City')
        self.assertEquals(events[1]['contact_email'], '*****@*****.**')
        self.assertEquals(events[1]['contact_phone'], '000 111 22 33')
        self.assertTrue('latitude' not in events[1])
        self.assertTrue('longitude' not in events[1])
        self.assertEquals(events[1]['start'], datetime(2017, 8, 25, 9, 15))
        self.assertEquals(events[1]['end'], datetime(2017, 8, 25, 20, 50))
        self.assertEquals(events[1]['recurrence'], '')
        self.assertEquals(events[1]['whole_day'], False)
        self.assertEquals(events[1]['timezone'], 'Europe/Zurich')
        self.assertEquals(events[1]['cat1'], set())
        self.assertEquals(events[1]['cat2'], set(['City']))

        self.assertEquals(events[2]['start'], datetime(2014, 3, 12, 0, 0))
        self.assertEquals(events[2]['end'], datetime(2014, 3, 12, 0, 0))
        self.assertEquals(events[2]['recurrence'],
                          'RRULE:FREQ=DAILY;UNTIL=20150101T0000Z')
        self.assertEquals(events[2]['whole_day'], True)

        self.assertEquals(events[3]['start'], datetime(2014, 1, 1, 7, 0))
        self.assertEquals(events[3]['end'], datetime(2014, 1, 1, 19, 0))
        self.assertEquals(events[3]['recurrence'],
                          'RRULE:FREQ=DAILY;UNTIL=20140215T0000Z')
        self.assertEquals(events[3]['whole_day'], False)
Exemplo n.º 3
0
    def test_guidle_import(self):
        xml = GUIDLE_TEST_DATA

        context = mock.Mock()
        context.url = 'url'

        source = EventsSourceGuidle(context)
        events = [event for event in source.fetch(xml)]
        self.assertEquals(len(events), 4)

        self.assertEquals(str(events[0]['last_update']),
                          '2013-07-26 16:00:43+02:00')
        self.assertEquals(events[0]['fetch_id'], 'url')
        self.assertEquals(events[0]['id'], '123')
        self.assertEquals(events[0]['source_id'], '123')
        self.assertEquals(events[0]['title'], 'Title')
        self.assertEquals(events[0]['short_description'], 'Description')
        self.assertEquals(events[0]['long_description'], 'Long Descritption')
        self.assertEquals(events[0]['location_url'], 'http://www.example.ch')
        self.assertEquals(events[0]['image'], 'http://www.example.ch/1.png')
        self.assertEquals(events[0]['organizer'], 'Company')
        self.assertEquals(events[0]['locality'], 'Address')
        self.assertEquals(events[0]['zipcode'], '1234')
        self.assertEquals(events[0]['town'], 'City')
        self.assertEquals(events[0]['contact_email'], '*****@*****.**')
        self.assertEquals(events[0]['contact_phone'], '000 111 22 33')
        self.assertEquals(events[0]['latitude'], '1.0')
        self.assertEquals(events[0]['longitude'], '2.0')
        self.assertEquals(events[0]['start'], datetime(2017, 8, 25, 0, 0))
        self.assertEquals(events[0]['end'], datetime(2017, 8, 25, 0, 0))
        self.assertEquals(events[0]['recurrence'],
                          'RRULE:FREQ=WEEKLY;BYDAY=MO,TU;UNTIL=20170904T0000Z')
        self.assertEquals(events[0]['whole_day'], True)
        self.assertEquals(events[0]['timezone'], 'Europe/Zurich')
        self.assertEquals(events[0]['cat1'], set())
        self.assertEquals(events[0]['cat2'], set(['City']))

        self.assertEquals(str(events[1]['last_update']),
                          '2013-07-26 16:00:43+02:00')
        self.assertEquals(events[1]['fetch_id'], 'url')
        self.assertEquals(events[1]['id'], '234')
        self.assertEquals(events[1]['source_id'], '234')
        self.assertEquals(events[1]['title'], 'Title')
        self.assertEquals(events[1]['short_description'], 'Description')
        self.assertEquals(events[1]['long_description'], 'Long Descritption')
        self.assertEquals(events[1]['location_url'], 'http://www.example.ch')
        self.assertEquals(events[1]['image'], 'http://www.example.ch/1.png')
        self.assertEquals(events[1]['organizer'], 'Company')
        self.assertEquals(events[1]['locality'], 'Address')
        self.assertEquals(events[1]['zipcode'], '1234')
        self.assertEquals(events[1]['town'], 'City')
        self.assertEquals(events[1]['contact_email'], '*****@*****.**')
        self.assertEquals(events[1]['contact_phone'], '000 111 22 33')
        self.assertTrue('latitude' not in events[1])
        self.assertTrue('longitude' not in events[1])
        self.assertEquals(events[1]['start'], datetime(2017, 8, 25, 9, 15))
        self.assertEquals(events[1]['end'], datetime(2017, 8, 25, 20, 50))
        self.assertEquals(events[1]['recurrence'], '')
        self.assertEquals(events[1]['whole_day'], False)
        self.assertEquals(events[1]['timezone'], 'Europe/Zurich')
        self.assertEquals(events[1]['cat1'], set())
        self.assertEquals(events[1]['cat2'], set(['City']))

        self.assertEquals(events[2]['start'], datetime(2014, 3, 12, 0, 0))
        self.assertEquals(events[2]['end'], datetime(2014, 3, 12, 0, 0))
        self.assertEquals(events[2]['recurrence'],
                          'RRULE:FREQ=DAILY;UNTIL=20150101T0000Z')
        self.assertEquals(events[2]['whole_day'], True)

        self.assertEquals(events[3]['start'], datetime(2014, 1, 1, 7, 0))
        self.assertEquals(events[3]['end'], datetime(2014, 1, 1, 19, 0))
        self.assertEquals(events[3]['recurrence'],
                          'RRULE:FREQ=DAILY;UNTIL=20140215T0000Z')
        self.assertEquals(events[3]['whole_day'], False)
Exemplo n.º 4
0
    def test_guidle_import(self):
        xml = """<?xml version="1.0" encoding="UTF-8"?>
<guidle:exportData xmlns:guidle="http://www.guidle.com">
  <guidle:groupSet>
    <guidle:group>
      <guidle:offer id="123">
        <guidle:lastUpdateDate>
          2013-07-26T16:00:43.208+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail>
          <guidle:title>Title</guidle:title>
          <guidle:shortDescription>Description</guidle:shortDescription>
          <guidle:longDescription>Long Descritption</guidle:longDescription>
          <guidle:homepage>http://www.example.ch</guidle:homepage>
          <guidle:images>
            <guidle:image>
              <guidle:url>http://www.example.ch/1.png</guidle:url>
            </guidle:image>
          </guidle:images>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:company>Address</guidle:company>
          <guidle:zip>1234</guidle:zip>
          <guidle:city>City</guidle:city>
          <guidle:country>Country</guidle:country>
          <guidle:latitude>1.0</guidle:latitude>
          <guidle:longitude>2.0</guidle:longitude>
        </guidle:address>
        <guidle:contact>
          <guidle:email>[email protected]</guidle:email>
          <guidle:telephone_1>000 111 22 33</guidle:telephone_1>
          <guidle:company>Company</guidle:company>
        </guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2017-08-25</guidle:startDate>
            <guidle:endDate>2017-09-03</guidle:endDate>
            <guidle:weekdays>
              <guidle:day>Mo</guidle:day>
              <guidle:day>Tu</guidle:day>
            </guidle:weekdays>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
      <guidle:offer id="234">
        <guidle:lastUpdateDate>
          2013-07-26T16:00:43.208+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail>
          <guidle:title>Title</guidle:title>
          <guidle:shortDescription>Description</guidle:shortDescription>
          <guidle:longDescription>Long Descritption</guidle:longDescription>
          <guidle:homepage>http://www.example.ch</guidle:homepage>
          <guidle:images>
            <guidle:image>
              <guidle:url>http://www.example.ch/1.png</guidle:url>
            </guidle:image>
          </guidle:images>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:company>Address</guidle:company>
          <guidle:zip>1234</guidle:zip>
          <guidle:city>City</guidle:city>
          <guidle:country>Country</guidle:country>
        </guidle:address>
        <guidle:contact>
          <guidle:email>[email protected]</guidle:email>
          <guidle:telephone_1>000 111 22 33</guidle:telephone_1>
          <guidle:company>Company</guidle:company>
        </guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2017-08-25</guidle:startDate>
            <guidle:endDate>2017-08-25</guidle:endDate>
            <guidle:startTime>09:15:00</guidle:startTime>
            <guidle:endTime>20:50:00</guidle:endTime>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
      <guidle:offer id="50_1">
        <guidle:lastUpdateDate>
          2014-05-28T11:20:35.736+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail id="345">
          <guidle:title>Issue 50</guidle:title>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:city>City</guidle:city>
        </guidle:address>
        <guidle:contact></guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2014-03-12</guidle:startDate>
            <guidle:endDate>2014-12-31</guidle:endDate>
            <guidle:startTime>00:00:00</guidle:startTime>
            <guidle:endTime>00:00:00</guidle:endTime>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
      <guidle:offer id="50_2">
        <guidle:lastUpdateDate>
          2014-05-28T11:20:35.736+02:00
        </guidle:lastUpdateDate>
        <guidle:offerDetail id="345">
          <guidle:title>Issue 50 (2)</guidle:title>
        </guidle:offerDetail>
        <guidle:address>
          <guidle:city>City</guidle:city>
        </guidle:address>
        <guidle:contact></guidle:contact>
        <guidle:schedules>
          <guidle:date>
            <guidle:startDate>2014-01-01</guidle:startDate>
            <guidle:endDate>2014-02-14</guidle:endDate>
            <guidle:startTime>07:00:00</guidle:startTime>
            <guidle:endTime>19:00:00</guidle:endTime>
          </guidle:date>
        </guidle:schedules>
        <guidle:classifications>
          <guidle:classification name="class">
          </guidle:classification>
        </guidle:classifications>
      </guidle:offer>
    </guidle:group>
  </guidle:groupSet>
</guidle:exportData>"""

        context = mock.Mock()
        context.url = 'url'

        source = EventsSourceGuidle(context)
        events = [event for event in source.fetch(xml)]
        self.assertEquals(len(events), 4)

        self.assertEquals(str(events[0]['last_update']),
                          '2013-07-26 16:00:43+02:00')
        self.assertEquals(events[0]['fetch_id'], 'url')
        self.assertEquals(events[0]['id'], '123')
        self.assertEquals(events[0]['source_id'], '123')
        self.assertEquals(events[0]['title'], 'Title')
        self.assertEquals(events[0]['short_description'], 'Description')
        self.assertEquals(events[0]['long_description'], 'Long Descritption')
        self.assertEquals(events[0]['location_url'], 'http://www.example.ch')
        self.assertEquals(events[0]['image'], 'http://www.example.ch/1.png')
        self.assertEquals(events[0]['organizer'], 'Company')
        self.assertEquals(events[0]['locality'], 'Address')
        self.assertEquals(events[0]['zipcode'], '1234')
        self.assertEquals(events[0]['town'], 'City')
        self.assertEquals(events[0]['contact_email'], '*****@*****.**')
        self.assertEquals(events[0]['contact_phone'], '000 111 22 33')
        self.assertEquals(events[0]['latitude'], '1.0')
        self.assertEquals(events[0]['longitude'], '2.0')
        self.assertEquals(events[0]['start'], datetime(2017, 8, 25, 0, 0))
        self.assertEquals(events[0]['end'], datetime(2017, 8, 25, 0, 0))
        self.assertEquals(events[0]['recurrence'],
                          'RRULE:FREQ=WEEKLY;BYDAY=MO,TU;UNTIL=20170904T0000Z')
        self.assertEquals(events[0]['whole_day'], True)
        self.assertEquals(events[0]['timezone'], 'Europe/Zurich')
        self.assertEquals(events[0]['cat1'], set())
        self.assertEquals(events[0]['cat2'], set(['City']))

        self.assertEquals(str(events[1]['last_update']),
                          '2013-07-26 16:00:43+02:00')
        self.assertEquals(events[1]['fetch_id'], 'url')
        self.assertEquals(events[1]['id'], '234')
        self.assertEquals(events[1]['source_id'], '234')
        self.assertEquals(events[1]['title'], 'Title')
        self.assertEquals(events[1]['short_description'], 'Description')
        self.assertEquals(events[1]['long_description'], 'Long Descritption')
        self.assertEquals(events[1]['location_url'], 'http://www.example.ch')
        self.assertEquals(events[1]['image'], 'http://www.example.ch/1.png')
        self.assertEquals(events[1]['organizer'], 'Company')
        self.assertEquals(events[1]['locality'], 'Address')
        self.assertEquals(events[1]['zipcode'], '1234')
        self.assertEquals(events[1]['town'], 'City')
        self.assertEquals(events[1]['contact_email'], '*****@*****.**')
        self.assertEquals(events[1]['contact_phone'], '000 111 22 33')
        self.assertTrue('latitude' not in events[1])
        self.assertTrue('longitude' not in events[1])
        self.assertEquals(events[1]['start'], datetime(2017, 8, 25, 9, 15))
        self.assertEquals(events[1]['end'], datetime(2017, 8, 25, 20, 50))
        self.assertEquals(events[1]['recurrence'], '')
        self.assertEquals(events[1]['whole_day'], False)
        self.assertEquals(events[1]['timezone'], 'Europe/Zurich')
        self.assertEquals(events[1]['cat1'], set())
        self.assertEquals(events[1]['cat2'], set(['City']))

        self.assertEquals(events[2]['start'], datetime(2014, 3, 12, 0, 0))
        self.assertEquals(events[2]['end'], datetime(2014, 3, 12, 0, 0))
        self.assertEquals(events[2]['recurrence'],
                          'RRULE:FREQ=DAILY;UNTIL=20150101T0000Z')
        self.assertEquals(events[2]['whole_day'], True)

        self.assertEquals(events[3]['start'], datetime(2014, 1, 1, 7, 0))
        self.assertEquals(events[3]['end'], datetime(2014, 1, 1, 19, 0))
        self.assertEquals(events[3]['recurrence'],
                          'RRULE:FREQ=DAILY;UNTIL=20140215T0000Z')
        self.assertEquals(events[3]['whole_day'], False)