コード例 #1
0
    def test_parse_event_batch(self):
        # Parsing the XML gives us two events.
        event1, event2 = EventParser().process_all(self.TWO_EVENTS)

        (threem_id, isbn, patron_id, start_time, end_time,
         internal_event_type) = event1

        eq_("theitem1", threem_id)
        eq_("900isbn1", isbn)
        eq_("patronid1", patron_id)
        eq_(CirculationEvent.DISTRIBUTOR_CHECKIN, internal_event_type)
        eq_(start_time, end_time)

        (threem_id, isbn, patron_id, start_time, end_time,
         internal_event_type) = event2
        eq_("theitem2", threem_id)
        eq_("900isbn2", isbn)
        eq_("patronid2", patron_id)
        eq_(CirculationEvent.DISTRIBUTOR_CHECKOUT, internal_event_type)

        # Verify that start and end time were parsed correctly.
        correct_start = datetime.datetime(2014, 4, 3, 0, 0, 34)
        correct_end = datetime.datetime(2014, 4, 2, 23, 57, 37)
        eq_(correct_start, start_time)
        eq_(correct_end, end_time)
コード例 #2
0
 def test_parse_empty_end_date_event(self):
     data = self.sample_data("empty_end_date_event.xml")
     [event] = list(EventParser().process_all(data))
     (threem_id, isbn, patron_id, start_time, end_time,
      internal_event_type) = event
     eq_('d5rf89', threem_id)
     eq_(u'9781101190623', isbn)
     eq_(None, patron_id)
     eq_(datetime.datetime(2016, 4, 28, 11, 4, 6), start_time)
     eq_(None, end_time)
     eq_('distributor_license_add', internal_event_type)