def btest_get_real_measures(self): print "In test_get_real_measures" raspi = RaspiFactory.getRaspi('Raspi') self.assertIsNotNone(raspi.get_temp_from_pi()) self.assertIsNotNone(raspi.get_charge_level()) self.assertIsNotNone(raspi.get_ph_from_pi()) self.assertIsNotNone(raspi.get_orp_from_pi())
def main(pool_settings, logger): do_update(pool_settings, logger) logger.debug('Initialising raspi...') raspi = None try: if boxsettings.FAKE_DATA: logger.info('Creating a Mock-Raspi..') raspi = RaspiFactory.getRaspi(pool_settings, 'mock') else: logger.info('Creating a real Raspi..') raspi = RaspiFactory.getRaspi(pool_settings, 'Raspi') except Exception, e: logger.fatal('Fail to init raspi', exc_info=True) if pool_settings.enable_shutdown() or BIGSHUTDOWN: logger.info('doing shutdown, as planned') raspi.shutdown() else: logger.fatal('No shutdown, as planned')
def btest_poolmaster(self): # if box settings has FAKE_DATA = True or not pool_settings = PoolSettings() raspi = RaspiFactory.getRaspi('Mock') poolmaster = PoolMaster(raspi) poolmaster.read_measures() self.assertTrue(poolmaster.readings_done) if pool_settings.is_online(): poolmaster.send_measures() self.assertTrue(poolmaster.sendings_done)
# checking if a shutdown should be made self.logger.debug('shutdown of pijuice...') bigshutdown = self.pool_settings.bigshutdown() self.logger.debug('pool_settings bigshutdown : %s' % bigshutdown) self.logger.info('We will MAKE a shutdown in %s seconds.' % seconds) self.pj.power.SetPowerOff(seconds) # 20 if __name__ == '__main__': logger = logging.getLogger() logger.setLevel(logging.DEBUG) # create console handler and set level to debug ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) logger.addHandler(ch) logger.info('Creating a real Raspi..') try: from box import RaspiFactory raspi = RaspiFactory.getRaspi('Raspi') logger.debug('Shutdown...') raspi.shutdown() except Exception, e: logger.fatal('Fail to init raspi', exc_info=True)
def btest_wakeup(self): raspi = RaspiFactory.getRaspi('Mock') raspi.setup_wakeup() raspi.shutdown()
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)
def btest_get_fake_measures(self): raspi = RaspiFactory.getRaspi('Mock') self.assertIsNotNone(raspi.get_temp_from_pi()) self.assertIsNotNone(raspi.get_charge_level()) self.assertIsNotNone(raspi.get_ph_from_pi()) self.assertIsNotNone(raspi.get_orp_from_pi())