mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Add a new command to generate fake devices for testing.
This commit is contained in:
parent
1c45b6eb70
commit
6acfa5b528
2 changed files with 86 additions and 0 deletions
53
lib/util/fakedevice.js
Normal file
53
lib/util/fakedevice.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
var util = require('util')
|
||||
|
||||
var uuid = require('node-uuid')
|
||||
|
||||
var dbapi = require('../db/api')
|
||||
|
||||
module.exports.generate = function() {
|
||||
var serial = util.format(
|
||||
'fake-%s'
|
||||
, uuid.v4(null, new Buffer(16)).toString('base64')
|
||||
)
|
||||
|
||||
return dbapi.saveDevice(serial, {
|
||||
provider: {
|
||||
name: 'FAKE/1'
|
||||
, channel: '*fake'
|
||||
}
|
||||
, status: 'OFFLINE'
|
||||
})
|
||||
.then(function() {
|
||||
return dbapi.saveDeviceIdentity(serial, {
|
||||
platform: 'Android'
|
||||
, manufacturer: 'Foo Electronics'
|
||||
, operator: 'Loss Networks'
|
||||
, model: 'F00'
|
||||
, version: '4.1.2'
|
||||
, abi: 'armeabi-v7a'
|
||||
, sdk: 8 + Math.floor(Math.random() * 12)
|
||||
, display: {
|
||||
density: 3
|
||||
, fps: 60
|
||||
, height: 1920
|
||||
, id: 0
|
||||
, orientation: 0
|
||||
, secure: true
|
||||
, url: '/404.jpg'
|
||||
, width: 1080
|
||||
, xdpi: 442
|
||||
, ydpi: 439
|
||||
}
|
||||
, phone: {
|
||||
iccid: '1234567890123456789'
|
||||
, imei: '123456789012345'
|
||||
, network: 'LTE'
|
||||
, phoneNumber: '0000000000'
|
||||
}
|
||||
})
|
||||
})
|
||||
.then(function() {
|
||||
return dbapi.setDeviceAbsent(serial)
|
||||
})
|
||||
.return(serial)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue