Exemplo n.º 1
0
    def test_get_data_points(self):
        node = Node()
        node.put()
        for _ in range(10):
            DataPoint(parent=node.key).put()

        self.assertEqual(10, len(node.data_points()))
Exemplo n.º 2
0
def handle(sms_message):
    message_body = sms_message.body
    if sms_message.to == '*****@*****.**':
        logging.info('Message received')
        return

    elif sms_message.to == '*****@*****.**':
        logging.info('Message received from: ' + sms_message.sender)
        return reply_farmer_id(sms_message.sender)

    elif sms_message.to == '*****@*****.**':
        farmer_id, node_id = message_body.split(' ')[1:]
        node = Node.get_by_node_id(node_id)
        if node is None:
            logging.error('Node not found')
            return send_sms(
                sms_message.sender,
                'You don\'t have any %s' % node_id
            )

        logging.info('Node found')
        return reply_node_status(sms_message.sender, node)
Exemplo n.º 3
0
 def test_get_by_node_id(self):
     node = Node(node_id='TEST').put()
     self.assertEqual(node, Node.get_by_node_id('TEST').key)