def set_probe(probe_id):
    probe = db_adapter.get_probe_by_id(probe_id)
    if probe is None:
        abort(400, 'Probe with id "' + probe_id + '" does not exist.')
    else:
        new_name = _get_parameter_value('name')
        master = _get_boolean_value("master")
        if new_name is not None:
            temperature_probes.set_probe_name(probe_id, new_name)
            print 'Set name of probe ' + probe_id + ' to ' + new_name        
        if master is not None:
            if master: 
                temperature_probes.set_probe_as_master(probe_id)
                print 'Probe ' + probe_id + ' is now the master probe.'
            else: 
                temperature_probes.set_probe_as_not_master(probe_id)
                print 'Probe ' + probe_id + ' is no longer the master probe.'                
    response.status = 204
 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