コード例 #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": {}},
    }
コード例 #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": {}
        },
    }
コード例 #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': {},
        },
    }
コード例 #4
0
def test_create(db_session, client):
    john = users.john()
    flight = flights.one(igc_file=igcs.simple(owner=john))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment, john)

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [{u"user": None, u"text": u"Yeah!"}]

    res = client.post(
        "/flights/{id}/comments".format(id=flight.id),
        headers=auth_for(john),
        json={u"text": u"foobar"},
    )
    assert res.status_code == 200
    assert res.json == {}

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [
        {
            u"user": None,
            u"text": u"Yeah!"
        },
        {
            u"user": {
                u"id": john.id,
                u"name": u"John Doe"
            },
            u"text": u"foobar"
        },
    ]
コード例 #5
0
def test_create(db_session, client):
    john = users.john()
    flight = flights.one(igc_file=igcs.simple(owner=john))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment, john)

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }]

    res = client.post('/flights/{id}/comments'.format(id=flight.id),
                      headers=auth_for(john),
                      json={
                          u'text': u'foobar',
                      })
    assert res.status_code == 200
    assert res.json == {}

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }, {
        u'user': {
            u'id': john.id,
            u'name': u'John Doe',
        },
        u'text': u'foobar',
    }]
コード例 #6
0
def test_unauthenticated(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment)

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }]

    res = client.post('/flights/{id}/comments'.format(id=flight.id),
                      json={
                          u'text': u'foobar',
                      })
    assert res.status_code == 401
    assert res.json == {
        u'error': u'invalid_token',
        u'message': u'Bearer token not found.',
    }

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }]
コード例 #7
0
def test_create(db_session, client):
    john = users.john()
    flight = flights.one(igc_file=igcs.simple(owner=john))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment, john)

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }]

    res = client.post('/flights/{id}/comments'.format(id=flight.id), headers=auth_for(john), json={
        u'text': u'foobar',
    })
    assert res.status_code == 200
    assert res.json == {}

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }, {
        u'user': {
            u'id': john.id,
            u'name': u'John Doe',
        },
        u'text': u'foobar',
    }]
コード例 #8
0
def test_unauthenticated(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment)

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }]

    res = client.post('/flights/{id}/comments'.format(id=flight.id), json={
        u'text': u'foobar',
    })
    assert res.status_code == 401
    assert res.json == {
        u'error': u'invalid_token',
        u'message': u'Bearer token not found.',
    }

    res = client.get('/flights/{id}?extended'.format(id=flight.id))
    assert res.status_code == 200
    assert res.json['comments'] == [{
        u'user': None,
        u'text': u'Yeah!',
    }]
コード例 #9
0
ファイル: read_test.py プロジェクト: RBE-Avionik/skylines
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': {},
        },
    }
コード例 #10
0
def test_unauthenticated(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment)

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [{u"user": None, u"text": u"Yeah!"}]

    res = client.post("/flights/{id}/comments".format(id=flight.id),
                      json={u"text": u"foobar"})
    assert res.status_code == 401
    assert res.json == {
        u"error": u"invalid_token",
        u"message": u"Bearer token not found.",
    }

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [{u"user": None, u"text": u"Yeah!"}]
コード例 #11
0
def test_unauthenticated(db_session, client):
    flight = flights.one(igc_file=igcs.simple(owner=users.john()))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment)

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [{u"user": None, u"text": u"Yeah!"}]

    res = client.post(
        "/flights/{id}/comments".format(id=flight.id), json={u"text": u"foobar"}
    )
    assert res.status_code == 401
    assert res.json == {
        u"error": u"invalid_token",
        u"message": u"Bearer token not found.",
    }

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [{u"user": None, u"text": u"Yeah!"}]
コード例 #12
0
def test_create(db_session, client):
    john = users.john()
    flight = flights.one(igc_file=igcs.simple(owner=john))
    comment = flight_comments.yeah(flight=flight)
    add_fixtures(db_session, flight, comment, john)

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [{u"user": None, u"text": u"Yeah!"}]

    res = client.post(
        "/flights/{id}/comments".format(id=flight.id),
        headers=auth_for(john),
        json={u"text": u"foobar"},
    )
    assert res.status_code == 200
    assert res.json == {}

    res = client.get("/flights/{id}?extended".format(id=flight.id))
    assert res.status_code == 200
    assert res.json["comments"] == [
        {u"user": None, u"text": u"Yeah!"},
        {u"user": {u"id": john.id, u"name": u"John Doe"}, u"text": u"foobar"},
    ]