def test_request_approval(self): context = self.mox.CreateMockAnything() context.make_request("activity", "APPROVAL", record_id="1", data=json.dumps([{"id": "1", "list_id": "1", "tag": "subject", "message": "hello"}])) self.mox.ReplayAll() record = Activity(context) record.backing = {"id": 1} record.request_approval("1", "subject", "hello") self.mox.VerifyAll()
def test_trigger(self): context = self.mox.CreateMockAnything() context.make_request("activity", "TRIGGER", record_id="1", data=json.dumps([{"id": "1", "test": 0, "request_content": "content", "conditions": ["1"]}])) self.mox.ReplayAll() record = Activity(context) record.backing = {"id": 1} record.trigger(["1"], "content", False) self.mox.VerifyAll()
def test_create(self): context = self.mox.CreateMockAnything() context.make_request("activity", "POST", data=json.dumps([{"ref": "ref", "revisions": []}])).AndReturn( json.dumps([{"id": 1, "ref": "ref", "revisions": []}])) self.mox.ReplayAll() record = Activity(context) record.backing = {"ref": "ref", "revisions": []} record.create() self.assertEqual("1", record.record_id) self.assertEqual("ref", record.ref) self.mox.VerifyAll()
def test_static_find(self): context = self.mox.CreateMockAnything() context.make_request("activity", "GET", parameters={"sort": "id", "order": "asc", "offset": "1", "limit": "100"}, query=["id-gt-1", "id-lt-100"]).AndReturn( json.dumps([{"id": 1, "revisions": []}, {"id": 2, "revisions": []}])) self.mox.ReplayAll() records = Activity.find(context, "id", "asc", 1, 100, ["id-gt-1", "id-lt-100"]) self.assertEqual(2, len(records)) self.mox.VerifyAll()
def test_static_get_with_content(self): context = self.mox.CreateMockAnything() context.make_request("activity", "GET", record_id=1, parameters={"revision": "latest"}).AndReturn( json.dumps([{"id": 1, "revisions": []}])) self.mox.ReplayAll() record = Activity.get_with_content(context, 1) self.assertTrue(isinstance(record, Activity)) self.assertEqual({"id": 1, "revisions": []}, record.backing) self.mox.VerifyAll()