Beispiel #1
0
  def test_singleton_events(self):
    instance_ref = self._create(n=1000)["ref"]

    self._q(query.update(instance_ref, {"data": {"n": 1001}}))
    self._q(query.delete(instance_ref))

    events = self._q(query.paginate(query.events(query.singleton(instance_ref))))["data"]

    self.assertEqual(len(events), 2)

    self.assertEqual(events[0]["action"], "add")
    self.assertEqual(events[0]["document"], instance_ref)

    self.assertEqual(events[1]["action"], "remove")
    self.assertEqual(events[1]["document"], instance_ref)
Beispiel #2
0
    def test_events(self):
        instance_ref = self._create(n=1000)["ref"]

        self._q(query.update(instance_ref, {"data": {"n": 1001}}))
        self._q(query.delete(instance_ref))

        events = self._q(query.paginate(query.events(instance_ref)))["data"]

        self.assertEqual(len(events), 3)

        self.assertEqual(events[0]["action"], "create")
        self.assertEqual(events[0]["document"], instance_ref)

        self.assertEqual(events[1]["action"], "update")
        self.assertEqual(events[1]["document"], instance_ref)

        self.assertEqual(events[2]["action"], "delete")
        self.assertEqual(events[2]["document"], instance_ref)
 def test_events(self):
     self.assertJson(
         query.events(query.ref(query.collection("widget"), "1")),
         '{"events":{"id":"1","ref":{"collection":"widget"}}}')
     self.assertJson(query.events(query.match(query.index("widget"))),
                     '{"events":{"match":{"index":"widget"}}}')