-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathoe-device-management-device-types.spec.ts
106 lines (93 loc) · 4.05 KB
/
oe-device-management-device-types.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import * as chai from "chai";
import "url-search-params-polyfill";
import { MindSphereSdk } from "../src";
import { decrypt, loadAuth, throwError } from "../src/api/utils";
import { setupDeviceTestStructure, tearDownDeviceTestStructure } from "./test-device-setup-utils";
import { getPasskeyForUnitTest } from "./test-utils";
chai.should();
describe.skip("[SDK] DeviceManagementClient.DeviceTypes", () => {
const auth = loadAuth();
const sdk = new MindSphereSdk({
...auth,
basicAuth: decrypt(auth, getPasskeyForUnitTest()),
});
const deviceManagementClient = sdk.GetDeviceManagementClient();
const tenant = sdk.GetTenant();
const testDeviceType = {
name: `${tenant}.UnitTestDeviceType`,
code: `${tenant}.V001`,
assetTypeId: `${tenant}.UnitTestDeviceAssetType`,
description: " example device type",
properties: {
key1: "value1",
key2: "value2",
},
};
let deviceTypeId = "aee2e37f-f562-4ed6-b90a-c43208dc054a";
let assetTypeId = `${tenant}.UnitTestDeviceAssetType`;
let assetId = "";
let deviceId = "";
let gFolderid = "";
before(async () => {
// tear Down test infrastructure
await tearDownDeviceTestStructure(sdk);
// Setup the testing architecture
const { device, deviceAsset, deviceType, deviceAssetType, folderid } = await setupDeviceTestStructure(sdk);
assetTypeId = `${(deviceAssetType as any).id}`;
deviceTypeId = `${(deviceType as any).id}`;
assetId = `${(deviceAsset as any).id}`;
deviceId = `${(device as any).id}`;
gFolderid = `${folderid}`;
});
after(async () => {
// tear Down test infrastructure
await tearDownDeviceTestStructure(sdk);
});
it("SDK should not be undefined", async () => {
sdk.should.not.be.undefined;
});
it("standard properties shoud be defined", async () => {
deviceManagementClient.should.not.be.undefined;
deviceManagementClient.GetGateway().should.be.equal(auth.gateway);
(await deviceManagementClient.GetToken()).length.should.be.greaterThan(200);
(await deviceManagementClient.GetToken()).length.should.be.greaterThan(200);
});
it("should GET device types @sanity", async () => {
deviceManagementClient.should.not.be.undefined;
const deviceTypes = await deviceManagementClient.GetDeviceTypes({
assetTypeId: `${tenant}.UnitTestDeviceAssetType`,
owner: `${tenant}`,
});
deviceTypes.should.not.be.undefined;
deviceTypes.should.not.be.null;
(deviceTypes as any).page.number.should.equal(0);
(deviceTypes as any).page.size.should.equal(10);
(deviceTypes as any).content.length.should.be.gte(1);
});
it("should GET device types with sorting", async () => {
deviceManagementClient.should.not.be.undefined;
const deviceTypes = await deviceManagementClient.GetDeviceTypes({
assetTypeId: `${tenant}.UnitTestDeviceAssetType`,
owner: `${tenant}`,
sort: "DESC",
page: 0,
size: 0,
});
deviceTypes.should.not.be.undefined;
deviceTypes.should.not.be.null;
deviceTypes.content || throwError("there have to be some devicetypes with that sort parameter!");
(deviceTypes as any).content.length.should.be.greaterThan(0);
});
it("should GET specific device type ", async () => {
deviceManagementClient.should.not.be.undefined;
const deviceType = await deviceManagementClient.GetDeviceType(deviceTypeId);
deviceType.should.not.be.null;
});
it("should PATCH specific device type ", async () => {
deviceManagementClient.should.not.be.undefined;
testDeviceType.name = `${tenant}.UnitTestDeviceType_B`;
const patchedDeviceType = await deviceManagementClient.PatchDeviceType(deviceTypeId, testDeviceType);
patchedDeviceType.should.not.be.null;
patchedDeviceType.name.should.be.string(`${tenant}.UnitTestDeviceType_B`);
});
});