Ejemplo n.º 1
0
    def test_create_step_should_raise_tripnotfoundexception(self):
        user = create_user("*****@*****.**")
        trip = create_trip(get_trip_object(name="trip", creator=user))
        start_datetime = "2020-04-10 21:00:00"

        with self.assertRaises(TripNotFoundException):
            create_step(
                get_step_object(name="step",
                                trip_id=trip.id + 1,
                                start_datetime=start_datetime))
Ejemplo n.º 2
0
    def test_create_step_with_no_name_should_raise_stringlengthoutofrangeexception(
            self):
        user = create_user("*****@*****.**")
        trip = create_trip(get_trip_object(name="trip", creator=user))
        start_datetime = "2020-04-10 21:00:00"
        name = ''

        with self.assertRaises(StringLengthOutOfRangeException):
            create_step(
                get_step_object(name=name,
                                trip_id=trip.id,
                                start_datetime=start_datetime))
Ejemplo n.º 3
0
    def test_get_user_personal_timeline(self):
        user = create_user("*****@*****.**")
        trip = create_trip(get_trip_object("trip", user))
        step = create_step(
            get_step_object("step", trip.id, "2020-05-03 10:00:00"))
        step2 = create_step(
            get_step_object("step2", trip.id, "2020-05-03 10:00:00"))
        step = add_participant_to_step(user.id, step.id)
        step2 = add_participant_to_step(user.id, step2.id)
        expected_result = [step, step2]

        self.assertListEqual(get_user_steps_participation(user, trip.id),
                             expected_result)
Ejemplo n.º 4
0
    def test_get_timeline_should_return_steps_ordered(self):
        user = create_user("*****@*****.**")
        trip = create_trip(get_trip_object(name="trip", creator=user))
        created_step_1 = create_step(
            get_step_object(name="step",
                            trip_id=trip.id,
                            start_datetime="2020-04-10 21:00:00"))
        created_step_2 = create_step(
            get_step_object(name="step",
                            trip_id=trip.id,
                            start_datetime="2020-04-05 21:00:00"))
        timeline = get_timeline(trip.id)

        self.assertEqual(timeline[0].id, created_step_2.id)
        self.assertEqual(timeline[1].id, created_step_1.id)
Ejemplo n.º 5
0
 def test_update_notes_with_too_long_string_should_raise_exception(self):
     user = create_user("*****@*****.**")
     trip = create_trip(get_trip_object("trip", user))
     step = create_step(
         get_step_object("step", trip.id, "2020-05-03 10:00:00"))
     with self.assertRaises(StringLengthOutOfRangeException):
         update_notes(step.id, 's' * 201)
Ejemplo n.º 6
0
 def test_add_participant_to_step_should_raise_stepnotfoundexception(self):
     user = create_user("*****@*****.**")
     trip = create_trip(get_trip_object("trip", user))
     step = create_step(
         get_step_object("step", trip.id, "2020-05-03 10:00:00"))
     with self.assertRaises(StepNotFoundException):
         add_participant_to_step(user.id, step.id + 1)
Ejemplo n.º 7
0
 def test_add_participant_to_step_should_add_user(self):
     user = create_user("*****@*****.**")
     trip = create_trip(get_trip_object("trip", user))
     step = create_step(
         get_step_object("step", trip.id, "2020-05-03 10:00:00"))
     step = add_participant_to_step(user.id, step.id)
     self.assertTrue(user in step.users_steps)
Ejemplo n.º 8
0
def get_ongoing_trips(user, current_date=datetime.date.today()):
    ongoing_trips = [get_trip_object("ongoing1", user)]
    ongoing_trips = create_trips(ongoing_trips)
    for trip in ongoing_trips:
        create_step(
            get_step_object(name="first",
                            trip_id=trip.id,
                            start_datetime=datetime.datetime(
                                current_date.year, current_date.month,
                                current_date.day, 8, 0, 0)))
        create_step(
            get_step_object(name="second",
                            trip_id=trip.id,
                            start_datetime=datetime.datetime(
                                current_date.year, current_date.month,
                                current_date.day, 10, 0, 0)))
    return ongoing_trips
Ejemplo n.º 9
0
 def test_should_update_notes(self):
     user = create_user("*****@*****.**")
     trip = create_trip(get_trip_object("trip", user))
     step = create_step(
         get_step_object("step", trip.id, "2020-05-03 10:00:00"))
     notes = 's' * 200
     update_notes(step.id, notes)
     self.assertEqual(notes, get_step_by_id(step.id).notes)
Ejemplo n.º 10
0
 def test_add_participant_to_step_should_raise_userdoesnotparticipatetotrip(
         self):
     creator = create_user("*****@*****.**")
     usurper = create_user("*****@*****.**")
     trip = create_trip(get_trip_object("trip", creator))
     step = create_step(
         get_step_object("step", trip.id, "2020-05-03 10:00:00"))
     with self.assertRaises(UserDoesNotParticipatesToTrip):
         add_participant_to_step(usurper.id, step.id)
Ejemplo n.º 11
0
 def test_create_step_should_succeed(self):
     user = create_user("*****@*****.**")
     trip = create_trip(get_trip_object(name="trip", creator=user))
     start_datetime = "2020-04-10 21:00:00"
     step = create_step(
         get_step_object(name="step",
                         trip_id=trip.id,
                         start_datetime=start_datetime))
     self.assertIsInstance(step, Step)
Ejemplo n.º 12
0
 def test_get_uncreated_step_should_return_none(self):
     user = create_user("*****@*****.**")
     trip = create_trip(get_trip_object(name="trip", creator=user))
     start_datetime = "2020-04-10 21:00:00"
     created_step = create_step(
         get_step_object(name="step",
                         trip_id=trip.id,
                         start_datetime=start_datetime))
     step = get_step_by_id(created_step.id + 1)
     self.assertEqual(step, None)
def add_test_step(trip: Trip,
                  participants: [User],
                  name: str,
                  start_datetime: datetime,
                  end_datetime=None) -> Step:
    step = Step(name=name,
                trip_id=trip.id,
                start_datetime=start_datetime,
                end_datetime=end_datetime,
                users_steps=participants)

    return create_step(step)
Ejemplo n.º 14
0
def get_coming_trips(user, current_date=datetime.date.today()):
    coming_trips = [
        get_trip_object("coming1", user),
        get_trip_object("coming2", user)
    ]
    coming_trips = create_trips(coming_trips)
    for trip in coming_trips:
        create_step(
            get_step_object(name="first",
                            trip_id=trip.id,
                            start_datetime=datetime.datetime(
                                current_date.year, current_date.month,
                                current_date.day + 1, 8, 0, 0)))
        create_step(
            get_step_object(name="second",
                            trip_id=trip.id,
                            start_datetime=datetime.datetime(
                                current_date.year, current_date.month,
                                current_date.day + 1, 10, 0, 0)))

    coming_trips.append(create_trip(get_trip_object("no steps", user)))
    return coming_trips
Ejemplo n.º 15
0
 def test_get_timeline_should_return_participant_of_step(self):
     user1 = create_user("*****@*****.**")
     user2 = create_user("*****@*****.**")
     trip = create_trip(get_trip_object(name="trip", creator=user1))
     invite_to_trip(trip_id=trip.id, user_to_invite_email=user2.email)
     step = create_step(
         get_step_object(name="step",
                         trip_id=trip.id,
                         start_datetime="2020-05-04 22:22:00"))
     add_participant_to_step(user_id=user1.id, step_id=step.id)
     add_participant_to_step(user_id=user2.id, step_id=step.id)
     timeline = get_timeline(trip_id=trip.id)
     participants = [user1, user2]
     self.assertEqual(timeline[0].users_steps, participants)