def check_hardware(skip_keyboard_input = False): # first the GPIO pins sound_check_passed = 'skip-gpio-test' in sys.argv; while not sound_check_passed: print 'Checking device control - you should hear both devices turn on/off or off/on...' time.sleep(1) try: chestfreezer_gpio.output_pin_for_time(configuration.heater_pin(), False, 1) time.sleep(1) chestfreezer_gpio.output_pin_for_time(configuration.freezer_pin(), False, 1) except ValueError as e: sys.exit('Pins could not be activated, reason:\n' + str(e) + '\nTerminating.') try: if skip_keyboard_input: raise termios.error # eclipse cannot handle this! sound_check_passed = do_sound_check() except termios.error: print 'You are using eclipse or some other IDE or are running tests, check passed.' sound_check_passed = True print 'GPIO pins #' + configuration.heater_pin() + ' and #' + configuration.freezer_pin() + ' connected correctly.' # then the temperature sensor(s) temperature_probes.initialize_probes() probes = temperature_probes.probe_ids if probes is None: sys.exit('No temperature probes were detected, check your wiring. Terminating.') else: print 'Found ' + str(len(probes)) + ' functional temperature sensor(s).' temperature_probes.determine_master_probe() if 'insert-test-data' in sys.argv: data_for_testing.insert_dummy_temperatures()
def setUpClass(self): chestfreezer_api.start(server_type = "wsgiref") time.sleep(1) chestfreezer_api.configuration.db_type = overwriten_db_type chestfreezer_api.configuration.set_should_send_emails(False) chestfreezer_api.configuration.set_is_security_enabled(True) db_adapter.connect() temperature_probes.initialize_probes() temperature_probes.determine_master_probe() self.http = httplib2.Http(".cache") print
def test_set_master_probe(self): temperature_probes.determine_master_probe() all_probes = db_adapter.get_all_probes() assert all_probes[0].master assert not all_probes[1].master assert not all_probes[2].master temperature_probes.master_probe_id = all_probes[0].probe_id # change the master probe temperature_probes.set_probe_as_master(all_probes[2].probe_id) all_probes = db_adapter.get_all_probes() assert not all_probes[0].master assert not all_probes[1].master assert all_probes[2].master temperature_probes.master_probe_id = all_probes[2].probe_id # set no probe to master temperature_probes.set_probe_as_not_master(all_probes[2].probe_id) all_probes = db_adapter.get_all_probes() assert not all_probes[0].master assert not all_probes[1].master assert not all_probes[2].master