def test_object(self): o = Object() o.config = Object() o.config.device = Object() o.config.device.name = "CTERA" o.config.device.uptime = "P0Y0M0DT0H0M24S" o.config.device.runningFirmware = "6.0.589.0" device_config = '{"config": ' \ '{"device": ' \ '{"name": "CTERA", "uptime": "P0Y0M0DT0H0M24S", "runningFirmware": "6.0.589.0"}' \ '}' \ '}' self.assertEqual(base_convert.TestJSON._tojsonstr(o), device_config)
def _get_test_server_object(): server_object = Object() server_object._uuid = str(uuid.uuid4()) # pylint: disable=protected-access server_object.uid = '123' server_object.username = '******' server_object.fullName = 'Test Unit' server_object.email = '*****@*****.**' server_object.password = '******' return server_object
def test_named_tuple(self): o = Object() o.name = "alice" o.email = "*****@*****.**" o.firstName = "Alice" o.lastName = "Wonderland" o.company = "Microsoft Corporation" o.showTutorial = True o.uid = 2156 o.password = None user_object = '<obj>' \ '<att id="name"><val>alice</val></att>' \ '<att id="email"><val>[email protected]</val></att>' \ '<att id="firstName"><val>Alice</val></att>' \ '<att id="lastName"><val>Wonderland</val></att>' \ '<att id="company"><val>Microsoft Corporation</val></att>' \ '<att id="showTutorial"><val>true</val></att>' \ '<att id="uid"><val>2156</val></att>' \ '<att id="password" />' \ '</obj>' self.assertEqual(base_convert.TestXML._toxmlstr(o), user_object)
def func(code, reason, msg=None): response = Object() if msg is not None: response.body = Object() response.body.msg = msg response.reason = reason response.code = code raise CTERAException(response=response)
def _get_test_acl_object(): acl_object = Object() acl_object.permissions = Object() acl_object.permissions.allowedFileAccess = gateway_enum.FileAccessMode.RW acl_object.principal2 = Object() acl_object.principal2._classname = gateway_enum.PrincipalType.LU # pylint: disable=protected-access acl_object.principal2.ref = 'test#admin' return acl_object
def test_null(self): o = Object() o.company = None self.assertEqual(base_convert.TestJSON._tojsonstr(o), '{"company": null}')
def test_sensitive_object(self): o = Object() o.password = '******' object_str_json = json.loads(base_convert.TestJSON._tojsonstr(o, False, True)) self.assertEqual(object_str_json['password'], "*** The Value is Hidden by the SDK ***")
def test_list(self): o = Object() o.drives = ['SATA-' + str(i) for i in range(1, 4)] self.assertEqual(base_convert.TestJSON._tojsonstr(o), '{"drives": ["SATA-1", "SATA-2", "SATA-3"]}')
def test_bool_false(self): o = Object() o.active = False self.assertEqual(base_convert.TestJSON._tojsonstr(o), '{"active": false}')
def test_bool_true(self): o = Object() o.active = True self.assertEqual(base_convert.TestJSON._tojsonstr(o), '{"active": true}')
def test_str(self): o = Object() o.name = "alice" self.assertEqual(base_convert.TestJSON._tojsonstr(o), '{"name": "alice"}')
def test_int(self): o = Object() o.uid = 2156 self.assertEqual(base_convert.TestJSON._tojsonstr(o), '{"uid": 2156}')
def _get_test_server_object(): server_object = Object() server_object.name = 'test' server_object.directory = '/dir' server_object.acl = [TestApiShares._get_test_acl_object()] server_object.access = gateway_enum.Acl.WindowsNT server_object.clientSideCaching = gateway_enum.ClientSideCaching.Manual server_object.dirPermissions = 777 server_object.comment = '' server_object.exportToAFP = False server_object.exportToFTP = False server_object.exportToNFS = False server_object.exportToPCAgent = False server_object.exportToRSync = False server_object.indexed = False server_object.trustedNFSClients = [ TestApiShares._get_test_trusted_nfs_clients_object() ] return server_object
def _get_test_trusted_nfs_clients_object(): trusted_nfs_clients_object = Object() trusted_nfs_clients_object.address = '192.168.1.0' trusted_nfs_clients_object.netmask = '255.255.255.0' trusted_nfs_clients_object.accessLevel = gateway_enum.FileAccessMode.RW return trusted_nfs_clients_object