示例#1
0
    def assert_loid(self, create=True, new=True):
        loid = LoId.load(self.request, self.context, create=create)
        self.assertIsNotNone(loid.loid)
        self.assertIsNotNone(loid.created)
        self.assertIs(loid.new, new)

        loid.save()

        if not new:
            self.assertFalse(bool(self.context.cookies.add.called))
            g.events.queue_production.assert_item_count(0)
        else:
            self.context.cookies.add.assert_has_calls(
                [
                    call(LOID_COOKIE, quote(loid.loid), expires=ANY),
                    call(LOID_CREATED_COOKIE, to_isodate(loid.created), expires=ANY),
                ]
            )
            payload = self.make_event_payload()
            payload.update(
                {
                    "loid_new": True,
                    "loid": loid.loid,
                    "loid_created": to_epoch_milliseconds(loid.created),
                    "loid_version": 0,
                }
            )
            g.events.queue_production.assert_event_item(
                dict(event_topic="loid_events", event_type="ss.create_loid", payload=payload)
            )
示例#2
0
 def make_returning_cookies(self):
     return {LOID_COOKIE: "foo", LOID_CREATED_COOKIE: to_isodate(datetime.now(pytz.UTC))}