This repository was archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathapp_mock.py
62 lines (47 loc) · 1.86 KB
/
app_mock.py
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
# coding: Latin-1
# Copyright © 2018 The Things Network
# Use of this source code is governed by the
# MIT license that can be found in the LICENSE file.
import ttn.github_com.TheThingsNetwork.api.handler.handler_pb2 as proto
class MockApplicationManager:
def __init__(self):
self.application = proto.Application()
self.applicationIdentifier = proto.ApplicationIdentifier()
self.device = proto.Device()
self.deviceIdentifier = proto.DeviceIdentifier()
self.deviceList = proto.DeviceList()
self.err = None
def reset(self):
self.application = None
self.applicationIdentifier = None
self.device = None
self.deviceIdentifier = None
self.deviceList = None
self.err = None
def RegisterApplication(self, appid, timeout, meta):
self.applicationIdentifier = appid
return {"err": self.err}
def GetApplication(self, req, timeout, meta):
self.applicationIdentifier = req
return {"application": self.application, "err": self.err}
def SetApplication(self, app, timeout, meta):
self.application = app
return {"err": self.err}
def DeleteApplication(self, appid, timeout, meta):
self.applicationIdentifier = appid
return {"err": self.err}
def GetDevice(self, devid, timeout, meta):
self.deviceIdentifier = devid
return self.device
def SetDevice(self, dev, timeout, meta):
self.device = dev
if self.deviceList == None:
self.deviceList = proto.DeviceList()
return {"err": self.err}
def DeleteDevice(self, devid, timeout, meta):
self.deviceIdentifier = devid
self.device = None
return {"err": self.err}
def GetDevicesForApplication(self, appid, timeout, meta):
self.applicationIdentifier = appid
return self.deviceList