Skip to content
test_restapi.py 1.34 KiB
Newer Older
Prasad's avatar
Prasad committed
#!/bin/python
# The content of this file is subject to ("Vtiger Public License 1.2") refer to LIECENSE for more details.
# Copyright (c) Vtiger.
# All Rights Reserved.
 
import unittest
import vtiger_cloudsdk_restapi

class TestRestApi(unittest.TestCase):

	def setUp(self):
		self.__client = vtiger_cloudsdk_restapi.Client(
Prasad's avatar
Prasad committed
                        "", #url
Prasad's avatar
Prasad committed
			"", #user
                        "", #pass
		)
		self.__MOCK_TEST_ACCOUNTNAME = "TestRestApiPython"

	def fetchMockTestAccount(self):
		records = self.__client.query("SELECT * FROM Accounts WHERE accountname = '"+ self.__MOCK_TEST_ACCOUNTNAME + "'" + " LIMIT 1;")
		return records.pop()

	def testMe(self):
		self.__client.me()

	def testListTypes(self):
		self.__client.list_types()

	def testDescribe(self):
		self.__client.describe("Accounts")

	def testCreate(self):
		self.__client.create("Accounts", {
			"accountname": self.__MOCK_TEST_ACCOUNTNAME,
			"assigned_user_id": self.__client.myid()
		})

	def testQuery(self):
		self.fetchMockTestAccount()

	def testUpdate(self):
		record = self.fetchMockTestAccount()
		record["website"] = "www.404.com"
		self.__client.update(record)

	def testRevise(self):
		account = self.fetchMockTestAccount()
		record = {}
		record["id"] = account["id"]
		record["website"] = "www.404-rev.com"
		self.__client.revise(record)


if __name__ == '__main__':
	unittest.main()