blob: 906d0d6f92b194d95f3ba2e24309eb2a561038ed [file] [log] [blame]
Weiweifea2f192015-07-21 17:06:44 -07001from device_profile import DeviceProfile
Weiweie5640c62015-07-31 01:43:01 -07002from pyndn import Name
Weiweifea2f192015-07-21 17:06:44 -07003
4def readProfile(profile):
5 print ' prefix: ', profile.getPrefix()
6 print ' location: ', profile.getLocation()
7 print ' manufacturer: ', profile.getManufacturer()
8 print ' category: ', profile.getCategory()
9 print ' type: ', profile.getType()
10 print ' serial number: ', profile.getSerialNumber()
11 print ' service profile list:', profile.getServiceProfileList()
12 print ' metadata', profile.getMetadata()
13
14def test():
15 print 'starting to test device_profile.py'
16 print "initilize with category ='sensors', serialNumer = 'T9000000'..."
17 profile = DeviceProfile(category = 'sensors', serialNumber = 'T9000000')
18
19 print 'read profile...'
20 readProfile(profile)
21
22 print "set prefix to '/home/sensor/LED/23'..."
Weiweie5640c62015-07-31 01:43:01 -070023 profile.setPrefix(Name('/home/sensor/LED/23'))
Weiweifea2f192015-07-21 17:06:44 -070024
25 print "set location to 'Alice's bedroom'..."
26 profile.setLocation('Alice\'s bedroom')
27
28 print "set manufacturer to 'Intel'..."
29 profile.setManufacturer('Intel')
30
31 print "set type to 'LED'..."
32 profile.setType('LED')
33
34 print "set serial number to 'T9273659'..."
35 profile.setSerialNumber('T9273659')
36
37 print "add a service profile '/standard/sensor/simple-LED-control/v0'..."
38 profile.addServiceProfile('/standard/sensor/simple-LED-control/v0')
39
40 print 'read profile...'
41 readProfile(profile)
42
43 print "add sevice profiles ['/standard/sensor/simple-camera-control/v0', '/standard/sensor/simple-motionsensor-control/v0']..."
44 profile.addServiceProfile(['/standard/sensor/simple-camera-control/v0', '/standard/sensor/simple-motionsensor-control/v0'])
45
46 print 'read profile...'
47 readProfile(profile)
48
49 print "set service profile to ['/standard/sensor/simple-camera-control/v0']... "
50 profile.setServiceProfile(['/standard/sensor/simple-camera-control/v0'])
51
52 print 'read profile...'
53 readProfile(profile)
54
55 print "add metadata 'name'... "
56 profile.addMetadata('name')
57
58 print 'read profile...'
59 readProfile(profile)
60
61 print "add metadata ['status', 'id']"
62 profile.addMetadata(['status', 'id'])
63
64 print 'read profile...'
65 readProfile(profile)
66
67 print "test 'print profile'..."
68 print profile
69
70 print "Unit tests: passed"
71
72if __name__ =='__main__':
73 test()
74