def test_save_bad_args(): args = [ { "uri": {}, # bad "type": "video", "live": False }, { "uri": "hello", "type": "boom", # bad "live": False }, { "uri": "test", "type": "video", "live": None # bad }, { "id": 3.14, "uri": "test", "type": "video", "live": True # bad }, ] for arg in args: try: if "id" not in arg.keys(): arg["id"] = "test" config_sources.save(arg["id"], arg) assert False except BadRequest: pass
def handle_config_source(source_id): if request.method == 'DELETE': config_sources.remove(source_id) return jsonify({'status': 'success'}) if request.method == 'PUT': source = request.get_json() config_sources.save(source_id, source) return jsonify(config_sources.get(source_id))
def test_save(): config = get_test_config() source_id = "test_add" result = config_sources.save(source_id, { "uri": source_id, "type": "video", "live": True, }) assert result["id"] == source_id source1 = config_manager.get()["sources"][source_id] assert config_manager.get()["sources"][source_id] assert source1["uri"] == source_id
def update_config_source(source: SensorSource): config_sources.save(source=source) return config_sources.get(source.id)