示例#1
0
    def lora_connection(self, requests_mock):
        # Mock the Authentication Handler
        requests_mock.get("https://loraserver/api/device-profiles",
                          json={
                              "result": [{
                                  "createdAt":
                                  "2019-04-18T14:44:03.093Z",
                                  "id":
                                  "54767cb5-beef-494e-dead-8821ddd69bcb",
                                  "name":
                                  "TEST_DEV_PROFILE",
                                  "networkServerID":
                                  "1",
                                  "organizationID":
                                  "1",
                                  "updatedAt":
                                  "2019-04-18T14:44:03.094Z"
                              }],
                              "totalCount":
                              "1"
                          })

        requests_mock.post(
            "https://loraserver/api/internal/login",
            json={
                "jwt":
                "eyJhbGciOiZXJ2ZXIiLCJleHAiOjE1NTU1OTk1ODMsImlzcyI6ImxvcmEtYXBwLXNlcnZlciIsIm5iZiI6MTU1NTUxMzE4Mywic3ViIjoidXNlciIsInVzZXJuYW1lIjoiYXBpYWNjb3VudCJ9.MBkIe1pxh51lB4-qRkjxlMaOa2HBnMhwk148wYrBDj0JIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJsb3JhLWFwcC1z"  # noqa: E501
            })
        from pyloraserver import loraserver
        return loraserver.Loraserver(loraserver_url="https://loraserver",
                                     loraserver_user="******",
                                     loraserver_pass="******")
示例#2
0
    def lora_connection(self, requests_mock):
        # Mock the Authentication Handler
        requests_mock.get(
            "https://loraserver/api/applications",
            json={
                "result": [{
                    "description":
                    "A test application from the test fixture",  # noqa: E501
                    "id": "1",
                    "name": "TEST_APPLICATION",
                    "organizationID": "1",
                    "serviceProfileID":
                    "54767cb5-beef-494e-dead-8821ddd69bcb",  # noqa: E501
                    "serviceProfileName": "testServiceProfile"
                }],
                "totalCount":
                "string"
            })

        requests_mock.post(
            "https://loraserver/api/internal/login",
            json={
                "jwt":
                "eyJhbGciOiZXJ2ZXIiLCJleHAiOjE1NTU1OTk1ODMsImlzcyI6ImxvcmEtYXBwLXNlcnZlciIsIm5iZiI6MTU1NTUxMzE4Mywic3ViIjoidXNlciIsInVzZXJuYW1lIjoiYXBpYWNjb3VudCJ9.MBkIe1pxh51lB4-qRkjxlMaOa2HBnMhwk148wYrBDj0JIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJsb3JhLWFwcC1z"  # noqa: E501
            })
        from pyloraserver import loraserver
        return loraserver.Loraserver(loraserver_url="https://loraserver",
                                     loraserver_user="******",
                                     loraserver_pass="******")
示例#3
0
 def lora_connection(self, requests_mock):
     # Mock the Authentication Handler
     requests_mock.post(
         "https://loraserver/api/internal/login",
         json={
             "jwt":
             "eyJhbGciOiZXJ2ZXIiLCJleHAiOjE1NTU1OTk1ODMsImlzcyI6ImxvcmEtYXBwLXNlcnZlciIsIm5iZiI6MTU1NTUxMzE4Mywic3ViIjoidXNlciIsInVzZXJuYW1lIjoiYXBpYWNjb3VudCJ9.MBkIe1pxh51lB4-qRkjxlMaOa2HBnMhwk148wYrBDj0JIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJsb3JhLWFwcC1z"  # noqa: E501
         })
     # Mock the device list
     requests_mock.get(
         "https://loraserver/api/devices?limit=100&applicationID=1",
         json={
             "totalCount":
             "1",
             "result": [{
                 "devEUI": "bebebebebebebebe",
                 "name": "asdf",
                 "applicationID": "7",
                 "description": "asdf",
                 "deviceProfileID":
                 "54767cb5-ba1b-494e-beef-8821ddd69bcb",  # noqa: E501
                 "deviceProfileName": "ODN_EU_02",
                 "deviceStatusBattery": 255,
                 "deviceStatusMargin": 256,
                 "deviceStatusExternalPowerSource": False,
                 "deviceStatusBatteryLevelUnavailable": True,
                 "deviceStatusBatteryLevel": 0,
                 "lastSeenAt": "2019-04-17T06:12:31.904650Z"
             }]
         })
     from pyloraserver import loraserver
     return loraserver.Loraserver(loraserver_url="https://loraserver",
                                  loraserver_user="******",
                                  loraserver_pass="******")