Update documentation regarding running tests when using a subdomain in application routing

Open
#2,903 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with tornado/test/routing_test.py, especially the HostMatchingTest cases linked in the issue, and locate the documentation section covering subdomain routing and AsyncHTTPTestCase. Document that subdomain-routed tests need an appropriate Host header, then verify the guidance matches the existing routing tests.

Written by the indexing model from the issue text.

Description

testing

I had an existing set of tests that subclass AsyncHTTPTestCase and call routes defined as /api/some/route via the self.fetch method. These work fine.

I decided that I would like the api stuff to live at a subdomain -- api.mysite.tld -- and I followed the instructions laid out here https://stackoverflow.com/a/25592711

I ran my existing tests and they, of course, didnt work. Did some digging and found this test case which seems to resolve the issue (I need to add a Host header in my test cases) https://github.com/tornadoweb/tornado/blob/master/tornado/test/routing_test.py#L199-L227 ( && the HostMatchingTest cases)

Long story long. I setup

app.add_handlers(r'^api\..*', API_ROUTES)

and needed to pass a header value of Host: api. in order to get my existing tests to pass.

Could the documentation be updated to talk about how to test when using subdomain routing? Where should this be outlined at? I wouldn't mind adding some verbiage

Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tornadoweb/tornado

All issues in tornadoweb/tornado

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.