예제 #1
0
 def btest_sender_batterycharge(self):
     sender = Sender()
     value = 10
     try:
         response = sender.send_battery_level(value)
         print(response.json())
         self.assertEqual(201, response.status_code)
     except:
         print("No connection possible to send battery_level")
예제 #2
0
def send_battery_charge_level(raspi, pool_settings, logger):
    logger.debug('send_battery_charge_level: pool_settings')
    logger.debug('Online: %s Reading: %s' %
                 (pool_settings.is_online(), pool_settings.enable_reading()))
    logger.debug('do_update pool_settings. do_update? %s ' %
                 pool_settings.do_update())

    try:
        sender = Sender()
        battery_level = raspi.get_charge_level()
        logger.info('Battery charge in percent: %s' % battery_level)
        if ONLINE:
            logger.info('ONLINE: Sending info to REST')
            response = sender.send_battery_level(battery_level)
            logger.info('Answer: %s' % response.status_code)
        else:
            logger.info(('NOT ONLINE. Battery level not sent'))
    except:
        logger.fatal("Cannot create pijuice object")
예제 #3
0
 def btest_send_charge_level(self):
     raspi = RaspiFactory.getRaspi('Mock')
     sender = Sender()
     if sender.is_online():
         response = sender.send_battery_level(raspi.get_charge_level())
         self.assertEqual(201, response.status_code)