Example #1
0
  def test_get_by_id_returns_expected(self):
    with self._app.app_context():
      # Setup.
      trips = []
      _add_trip(trips=trips, trip_id=1, trip_hash_id='a', title='Tahoe', activity_name='Hike',
                start=datetime.date(2016, 1, 1), end=datetime.date(2016, 1, 10))

      _add_trip(trips=trips, trip_id=2, trip_hash_id='b', title='Yosemitee', activity_name='Hike',
                start=datetime.date(2016, 2, 20), end=datetime.date(2016, 3, 29))

      _add_trip(trips=trips, trip_id=3, trip_hash_id='c', title='Kings Canyon',
                activity_name='Hike', start=datetime.date(2016, 2, 21),
                end=datetime.date(2016, 4, 10))
      _insert_trips(trips)

      # Exercise.
      trip = trips_models.get_by_hash_id(trip_hash_id='b')

      # Verify.
      self.assertEqual(2, trip.trip_id)
Example #2
0
def get_trip(hash_id):
  '''Gets a list of trips with the given parameters.'''
  trip = trips_models.get_by_hash_id(hash_id)

  return jsonify(trip.as_dict())