def update_station(station: dict): updated_station = StationModel.update(station) if not updated_station: raise EntityNotFound("This station doesn't exist.") return response.bool_to_response(updated_station.save())
def test_channel_model(self): station: StationModel = StationModel.find_by(name="04A", creation_date="2016/159") self.assertIsNotNone(station) setup: ChannelModel = ChannelModel.find_by(station_id=station.id, start_time="2016/159") self.assertIsNotNone(setup) print(setup.to_dict()) print(setup.equipments)
def delete_station(station_id): station: StationModel = StationModel.find_by_id(station_id) if not station: raise EntityNotFound( "The station id {} doesn't exist".format(station_id)) deleted = station.delete() if deleted: app_logger.info("Station {} - {} has been deleted".format( station.name, station.creation_date)) else: app_logger.warning("Station {} - {} could't be deleted.".format( station.name, station.creation_date)) return response.bool_to_response(deleted)
def test_station_model(self): station: StationModel = StationModel.find_by( name="04A", creation_date="2016/06/07") self.assertIsNotNone(station) print(station.to_dict()) print(station.channels)
def create_station(station_dict: dict): was_created = StationModel.create_station(station_dict) return response.bool_to_response(was_created)
def search_stations(station_search: Search): search_result: SearchResult = StationModel.search(station_search) return response.model_to_response(search_result)
def get_station(station_id: str): station = StationModel.find_by_id(station_id) if station: return response.model_to_response(station) return response.empty_response()