def test_to_json(self): handle = AllocationHandle("test_id") expected_json = {AllocationHandle.HANDLE_ID: "test_id", AllocationHandle.BLOCK: {}} json_str = handle.to_json() json_result = json.loads(json_str) assert_dict_equal(expected_json, json_result) block_cidr = IPNetwork("10.11.12.0/24") handle.increment_block(block_cidr, 5) expected_json[AllocationHandle.BLOCK]["10.11.12.0/24"] = 5 json_str = handle.to_json() json_result = json.loads(json_str) assert_dict_equal(expected_json, json_result) block_cidr2 = IPNetwork("10.11.45.0/24") handle.increment_block(block_cidr2, 20) expected_json[AllocationHandle.BLOCK]["10.11.45.0/24"] = 20 json_str = handle.to_json() json_result = json.loads(json_str) assert_dict_equal(expected_json, json_result)
def test_to_json(self): handle = AllocationHandle("test_id") expected_json = { AllocationHandle.HANDLE_ID: "test_id", AllocationHandle.BLOCK: {} } json_str = handle.to_json() json_result = json.loads(json_str) assert_dict_equal(expected_json, json_result) block_cidr = IPNetwork("10.11.12.0/24") handle.increment_block(block_cidr, 5) expected_json[AllocationHandle.BLOCK]["10.11.12.0/24"] = 5 json_str = handle.to_json() json_result = json.loads(json_str) assert_dict_equal(expected_json, json_result) block_cidr2 = IPNetwork("10.11.45.0/24") handle.increment_block(block_cidr2, 20) expected_json[AllocationHandle.BLOCK]["10.11.45.0/24"] = 20 json_str = handle.to_json() json_result = json.loads(json_str) assert_dict_equal(expected_json, json_result)