seperate the tests

This commit is contained in:
sessionm21 2020-05-12 22:01:21 +01:00
parent 5dc3587ccb
commit d86cd5b72e
2 changed files with 16 additions and 8 deletions

View File

@ -41,14 +41,6 @@ def on_message(client, userdata, msg):
res.ParseFromString(bcode)
store_coord(payload['dev_id'], res.loc.x, res.loc.y)
# Test protobuf here
# code = bytearray('CgoNAAAAABUAAAAA', "utf-8")
# print(code)
# bcode = base64.b64decode(code)
# res = message_pb2.CollarResponse()
# res.ParseFromString(bcode)
# print("Coord {x: " + str(res.loc.x) + ", y: " + str(res.loc.y) + "}")
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

16
tests.py Normal file
View File

@ -0,0 +1,16 @@
import paho.mqtt.client as mqtt
import json
import base64
import message_pb2
import sqlite3
# Test protobuf here
code = bytearray('CgoNAAAAABUAAAAA', "utf-8")
print(code)
bcode = base64.b64decode(code)
res = message_pb2.CollarResponse()
res.ParseFromString(bcode)
assert res.loc.x == 0
assert res.loc.y == 0
print("Coord {x: " + str(res.loc.x) + ", y: " + str(res.loc.y) + "}")