예제 #1
0
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())
예제 #2
0
 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)
예제 #3
0
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)
예제 #4
0
 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)
예제 #5
0
def create_station(station_dict: dict):
    was_created = StationModel.create_station(station_dict)
    return response.bool_to_response(was_created)
예제 #6
0
def search_stations(station_search: Search):
    search_result: SearchResult = StationModel.search(station_search)
    return response.model_to_response(search_result)
예제 #7
0
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()