graphql-python / graphql-python/sanic-graphql

Bad Test

Đang mở
#11 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
148
Fork
17
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

FYI: [this test](https://github.com/graphql-python/sanic-graphql/blob/36a940327071bb0c019d8881d170fd7c7a85713a/tests/test_graphqlview.py#L481) will never run (or it will always run, but it shouldn't).

I'm in the process of porting this to `aiohttp` and found this...

I believe the test is all kinds of wrong.
* its name doesn't match what it does (it has nothing to do with pretty printing)
* I don't understand why 'request' would resolve to `{}`. I'd assume it'd be repr'd to ``

I believe the test **ought to** test that 'CUSTOM CONTEXT' is replaced with an empty dict. at least that's what the code will do when `get_context(request)` is called and it discovers that self.context is not a dict.

Here's my replacement test (note, this isn't written for sanic, but the premise holds):
```
@pytest.mark.asyncio
async def test_context_remapped(self, client, url_builder):
response = await client.get(url_builder(query='{context}'))

_json = await response.json()
assert response.status == 200
assert 'request' in _json['data']['context']
assert 'CUSTOM CONTEXT' not in _json['data']['context']
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.