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