Ejemplo n.º 1
0
def test_comments(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment1 = flight_comments.yeah(flight=flight)
    comment2 = flight_comments.emoji(flight=flight)
    comment3 = flight_comments.yeah(
        flight=flight, user=flight.igc_file.owner, text=u"foo"
    )
    comment4 = flight_comments.yeah(flight=flight, text=u"bar")
    comment5 = flight_comments.yeah(flight=flight, user=users.jane(), text=u"baz")
    add_fixtures(db_session, flight, comment1, comment2, comment3, comment4, comment5)

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json == {
        u"flight": expected_basic_flight_json(flight),
        u"near_flights": [],
        u"comments": [
            {u"user": None, u"text": u"Yeah!"},
            {u"user": None, u"text": u"\U0001f44d"},
            {u"user": {u"id": comment3.user.id, u"name": u"John Doe"}, u"text": u"foo"},
            {u"user": None, u"text": u"bar"},
            {u"user": {u"id": comment5.user.id, u"name": u"Jane Doe"}, u"text": u"baz"},
        ],
        u"contest_legs": {u"classic": [], u"triangle": []},
        u"phases": [],
        u"performance": {u"circling": [], u"cruise": {}},
    }
Ejemplo n.º 2
0
def test_comments(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment1 = flight_comments.yeah(flight=flight)
    comment2 = flight_comments.emoji(flight=flight)
    comment3 = flight_comments.yeah(flight=flight,
                                    user=flight.igc_file.owner,
                                    text=u"foo")
    comment4 = flight_comments.yeah(flight=flight, text=u"bar")
    comment5 = flight_comments.yeah(flight=flight,
                                    user=users.jane(),
                                    text=u"baz")
    add_fixtures(db_session, flight, comment1, comment2, comment3, comment4,
                 comment5)

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json == {
        u"flight":
        expected_basic_flight_json(flight),
        u"near_flights": [],
        u"comments": [
            {
                u"user": None,
                u"text": u"Yeah!"
            },
            {
                u"user": None,
                u"text": u"\U0001f44d"
            },
            {
                u"user": {
                    u"id": comment3.user.id,
                    u"name": u"John Doe"
                },
                u"text": u"foo"
            },
            {
                u"user": None,
                u"text": u"bar"
            },
            {
                u"user": {
                    u"id": comment5.user.id,
                    u"name": u"Jane Doe"
                },
                u"text": u"baz"
            },
        ],
        u"contest_legs": {
            u"classic": [],
            u"triangle": []
        },
        u"phases": [],
        u"performance": {
            u"circling": [],
            u"cruise": {}
        },
    }
Ejemplo n.º 3
0
def test_comments(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment1 = flight_comments.yeah(flight=flight)
    comment2 = flight_comments.emoji(flight=flight)
    comment3 = flight_comments.yeah(flight=flight,
                                    user=flight.igc_file.owner,
                                    text='foo')
    comment4 = flight_comments.yeah(flight=flight, text='bar')
    comment5 = flight_comments.yeah(flight=flight,
                                    user=users.jane(),
                                    text='baz')
    add_fixtures(db_session, flight, comment1, comment2, comment3, comment4,
                 comment5)

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json == {
        u'flight':
        expected_basic_flight_json(flight),
        u'near_flights': [],
        u'comments': [{
            u'user': None,
            u'text': u'Yeah!',
        }, {
            u'user': None,
            u'text': u'\U0001f44d',
        }, {
            u'user': {
                u'id': comment3.user.id,
                u'name': u'John Doe'
            },
            u'text': u'foo',
        }, {
            u'user': None,
            u'text': u'bar',
        }, {
            u'user': {
                u'id': comment5.user.id,
                u'name': u'Jane Doe'
            },
            u'text': u'baz',
        }],
        u'contest_legs': {
            u'classic': [],
            u'triangle': [],
        },
        u'phases': [],
        u'performance': {
            u'circling': [],
            u'cruise': {},
        },
    }
Ejemplo n.º 4
0
def test_comments(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment1 = flight_comments.yeah(flight=flight)
    comment2 = flight_comments.emoji(flight=flight)
    comment3 = flight_comments.yeah(flight=flight, user=flight.igc_file.owner, text=u'foo')
    comment4 = flight_comments.yeah(flight=flight, text=u'bar')
    comment5 = flight_comments.yeah(flight=flight, user=users.jane(), text=u'baz')
    add_fixtures(db_session, flight, comment1, comment2, comment3, comment4, comment5)

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json == {
        u'flight': expected_basic_flight_json(flight),
        u'near_flights': [],
        u'comments': [{
            u'user': None,
            u'text': u'Yeah!',
        }, {
            u'user': None,
            u'text': u'\U0001f44d',
        }, {
            u'user': {
                u'id': comment3.user.id,
                u'name': u'John Doe'
            },
            u'text': u'foo',
        }, {
            u'user': None,
            u'text': u'bar',
        }, {
            u'user': {
                u'id': comment5.user.id,
                u'name': u'Jane Doe'
            },
            u'text': u'baz',
        }],
        u'contest_legs': {
            u'classic': [],
            u'triangle': [],
        },
        u'phases': [],
        u'performance': {
            u'circling': [],
            u'cruise': {},
        },
    }
Ejemplo n.º 5
0
def test_event_types(db_session, client):
    john = users.john()
    jane = users.jane()
    lva = clubs.lva()
    add_fixtures(db_session, john, jane, lva)

    flight = flights.one(igc_file=igcs.simple(owner=john))
    flight_comment = flight_comments.emoji(flight=flight, user=john)
    add_fixtures(db_session, flight, flight_comment)

    flight_event = events.flight(flight)
    flight_comment_event = events.flight_comment(flight_comment)
    follower_event = events.follower(actor=john, user=jane)
    new_user_event = events.new_user(jane)
    club_join_event = events.club_join(actor=john, club=lva)
    add_fixtures(
        db_session,
        flight_event,
        flight_comment_event,
        follower_event,
        new_user_event,
        club_join_event,
    )

    res = client.get("/timeline")
    assert res.status_code == 200
    assert res.json == {
        "events": [
            {
                "id": club_join_event.id,
                "type": "club-join",
                "time": "2017-02-15T12:34:56+00:00",
                "actor": {
                    "id": john.id,
                    "name": "John Doe"
                },
                "club": {
                    "id": club_join_event.club.id,
                    "name": "LV Aachen"
                },
            },
            {
                "id": new_user_event.id,
                "type": "new-user",
                "time": "2017-02-14T12:34:56+00:00",
                "actor": {
                    "id": jane.id,
                    "name": "Jane Doe"
                },
            },
            {
                "id": follower_event.id,
                "type": "follower",
                "time": "2017-02-13T12:34:56+00:00",
                "actor": {
                    "id": john.id,
                    "name": "John Doe"
                },
                "user": {
                    "id": jane.id,
                    "name": "Jane Doe"
                },
            },
            {
                "id": flight_event.id,
                "type": "flight-upload",
                "time": "2017-02-12T12:34:56+00:00",
                "actor": {
                    "id": john.id,
                    "name": "John Doe"
                },
                "flight": {
                    "id": flight.id,
                    "date": "2011-06-18",
                    "pilot_id": john.id,
                    "copilot_id": None,
                    "distance": None,
                },
            },
            {
                "id": flight_comment_event.id,
                "type": "flight-comment",
                "time": "2017-02-11T12:34:56+00:00",
                "actor": {
                    "id": john.id,
                    "name": "John Doe"
                },
                "flightComment": {
                    "id": flight_comment.id
                },
                "flight": {
                    "id": flight.id,
                    "date": "2011-06-18",
                    "pilot_id": john.id,
                    "copilot_id": None,
                    "distance": None,
                },
            },
        ]
    }
Ejemplo n.º 6
0
def test_event_types(db_session, client):
    john = users.john()
    jane = users.jane()
    lva = clubs.lva()
    add_fixtures(db_session, john, jane, lva)

    flight = flights.one(igc_file=igcs.simple(owner=john))
    flight_comment = flight_comments.emoji(flight=flight, user=john)
    add_fixtures(db_session, flight, flight_comment)

    flight_event = events.flight(flight)
    flight_comment_event = events.flight_comment(flight_comment)
    follower_event = events.follower(actor=john, user=jane)
    new_user_event = events.new_user(jane)
    club_join_event = events.club_join(actor=john, club=lva)
    add_fixtures(db_session, flight_event, flight_comment_event,
                 follower_event, new_user_event, club_join_event)

    res = client.get('/timeline')
    assert res.status_code == 200
    assert res.json == {
        'events': [{
            'id': club_join_event.id,
            'type': 'club-join',
            'time': '2017-02-15T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'club': {
                'id': club_join_event.club.id,
                'name': 'LV Aachen',
            },
        }, {
            'id': new_user_event.id,
            'type': 'new-user',
            'time': '2017-02-14T12:34:56',
            'actor': {
                'id': jane.id,
                'name': 'Jane Doe',
            },
        }, {
            'id': follower_event.id,
            'type': 'follower',
            'time': '2017-02-13T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'user': {
                'id': jane.id,
                'name': 'Jane Doe',
            },
        }, {
            'id': flight_event.id,
            'type': 'flight-upload',
            'time': '2017-02-12T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'flight': {
                'id': flight.id,
                'date': '2011-06-18',
                'pilot_id': john.id,
                'copilot_id': None,
                'distance': None,
            },
        }, {
            'id': flight_comment_event.id,
            'type': 'flight-comment',
            'time': '2017-02-11T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'flightComment': {
                'id': flight_comment.id,
            },
            'flight': {
                'id': flight.id,
                'date': '2011-06-18',
                'pilot_id': john.id,
                'copilot_id': None,
                'distance': None,
            },
        }]
    }
Ejemplo n.º 7
0
def test_event_types(db_session, client):
    john = users.john()
    jane = users.jane()
    flight = flights.one(igc_file=igcs.simple(owner=john))
    flight_comment = flight_comments.emoji(flight=flight)

    flight_event = events.flight(actor=john, flight=flight)
    flight_comment_event = events.flight_comment(actor=john, flight=flight, flight_comment=flight_comment)
    follower_event = events.follower(actor=john, user=jane)
    new_user_event = events.new_user(actor=jane)
    club_join_event = events.club_join(actor=john, club=clubs.lva())
    add_fixtures(db_session, flight_event, flight_comment_event, follower_event, new_user_event, club_join_event)

    res = client.get('/timeline')
    assert res.status_code == 200
    assert res.json == {
        'events': [{
            'id': club_join_event.id,
            'type': 'club-join',
            'time': '2017-02-15T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'club': {
                'id': club_join_event.club.id,
                'name': 'LV Aachen',
            },
        }, {
            'id': new_user_event.id,
            'type': 'new-user',
            'time': '2017-02-14T12:34:56',
            'actor': {
                'id': jane.id,
                'name': 'Jane Doe',
            },
        }, {
            'id': follower_event.id,
            'type': 'follower',
            'time': '2017-02-13T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'user': {
                'id': jane.id,
                'name': 'Jane Doe',
            },
        }, {
            'id': flight_event.id,
            'type': 'flight-upload',
            'time': '2017-02-12T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'flight': {
                'id': flight.id,
                'date': '2011-06-18',
                'pilot_id': john.id,
                'copilot_id': None,
                'distance': None,
            },
        }, {
            'id': flight_comment_event.id,
            'type': 'flight-comment',
            'time': '2017-02-11T12:34:56',
            'actor': {
                'id': john.id,
                'name': 'John Doe',
            },
            'flightComment': {
                'id': flight_comment.id,
            },
            'flight': {
                'id': flight.id,
                'date': '2011-06-18',
                'pilot_id': john.id,
                'copilot_id': None,
                'distance': None,
            },
        }]
    }
Ejemplo n.º 8
0
def test_event_types(db_session, client):
    john = users.john()
    jane = users.jane()
    lva = clubs.lva()
    add_fixtures(db_session, john, jane, lva)

    flight = flights.one(igc_file=igcs.simple(owner=john))
    flight_comment = flight_comments.emoji(flight=flight, user=john)
    add_fixtures(db_session, flight, flight_comment)

    flight_event = events.flight(flight)
    flight_comment_event = events.flight_comment(flight_comment)
    follower_event = events.follower(actor=john, user=jane)
    new_user_event = events.new_user(jane)
    club_join_event = events.club_join(actor=john, club=lva)
    add_fixtures(
        db_session,
        flight_event,
        flight_comment_event,
        follower_event,
        new_user_event,
        club_join_event,
    )

    res = client.get("/timeline")
    assert res.status_code == 200
    assert res.json == {
        "events": [
            {
                "id": club_join_event.id,
                "type": "club-join",
                "time": "2017-02-15T12:34:56+00:00",
                "actor": {"id": john.id, "name": "John Doe"},
                "club": {"id": club_join_event.club.id, "name": "LV Aachen"},
            },
            {
                "id": new_user_event.id,
                "type": "new-user",
                "time": "2017-02-14T12:34:56+00:00",
                "actor": {"id": jane.id, "name": "Jane Doe"},
            },
            {
                "id": follower_event.id,
                "type": "follower",
                "time": "2017-02-13T12:34:56+00:00",
                "actor": {"id": john.id, "name": "John Doe"},
                "user": {"id": jane.id, "name": "Jane Doe"},
            },
            {
                "id": flight_event.id,
                "type": "flight-upload",
                "time": "2017-02-12T12:34:56+00:00",
                "actor": {"id": john.id, "name": "John Doe"},
                "flight": {
                    "id": flight.id,
                    "date": "2011-06-18",
                    "pilot_id": john.id,
                    "copilot_id": None,
                    "distance": None,
                },
            },
            {
                "id": flight_comment_event.id,
                "type": "flight-comment",
                "time": "2017-02-11T12:34:56+00:00",
                "actor": {"id": john.id, "name": "John Doe"},
                "flightComment": {"id": flight_comment.id},
                "flight": {
                    "id": flight.id,
                    "date": "2011-06-18",
                    "pilot_id": john.id,
                    "copilot_id": None,
                    "distance": None,
                },
            },
        ]
    }