def get_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:
        response.content_type = 'application/json;' 
        return json_parser.get_probe_as_json(probe)
 def test_set_probe_master(self):
     response = self._call_PUT_with_credentials_and_body('http://localhost:8080/chestfreezer/api/probe/' + str(temperature_probes.master_probe_id), '{"master":"false"}', 'application/json')[0]
     assert(response.status == 204)
     assert(not temperature_probes.master_probe_id)
     new_master_probe_id = str(temperature_probes.probe_ids[2])
     response = self._call_PUT_with_credentials_and_body('http://localhost:8080/chestfreezer/api/probe/' + new_master_probe_id, '{"master":"TRUE"}', 'application/json')[0]
     assert(response.status == 204)
     assert(temperature_probes.master_probe_id == new_master_probe_id)
     assert(db_adapter.get_probe_by_id(new_master_probe_id).master)        
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_probe_name(self):         
     second_probe_id = temperature_probes.probe_ids[0]
     response = self._call_PUT_with_credentials_and_body('http://localhost:8080/chestfreezer/api/probe/' + second_probe_id, '{"name":"new_name", "master":"true"}', 'application/json')[0]
     assert(response.status == 204)
     assert(db_adapter.get_probe_by_id(second_probe_id).name == 'new_name')