示例#1
0
    def test_create(self):
        context = self.mox.CreateMockAnything()
        context.make_request("template", "POST",
            data=json.dumps([{"ref": "ref", "revisions": []}])).AndReturn(
            json.dumps([{"id": 1, "ref": "ref", "revisions": []}]))
        self.mox.ReplayAll()

        record = Template(context)
        record.backing = {"ref": "ref", "revisions": []}
        record.create()
        self.assertEqual("1", record.record_id)
        self.assertEqual("ref", record.ref)
        self.mox.VerifyAll()
示例#2
0
    def test_static_find(self):
        context = self.mox.CreateMockAnything()
        context.make_request("template", "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 = Template.find(context, "id", "asc", 1, 100, ["id-gt-1", "id-lt-100"])
        self.assertEqual(2, len(records))
        self.mox.VerifyAll()
示例#3
0
    def test_static_get_with_content(self):
        context = self.mox.CreateMockAnything()
        context.make_request("template", "GET", record_id=1, 
            parameters={"revision": "latest"}).AndReturn(
            json.dumps([{"id": 1, "revisions": []}]))
        self.mox.ReplayAll()

        record = Template.get_with_content(context, 1)
        self.assertTrue(isinstance(record, Template))
        self.assertEqual({"id": 1, "revisions": []}, record.backing)
        self.mox.VerifyAll()
示例#4
0
 def setUp(self):
     mox.MoxTestBase.setUp(self)
     self.record = Template(None) 
     self.record.backing = {"id": 1, "status": "", "revisions": []}