Pylons / pyramid-cookiecutter-starter

A Cookiecutter (project template) for creating a Pyramid starter project with choices for template language (Jinja2, Chameleon, or Mako), persistent backend (none, SQLAlchemy with SQLite, or ZODB), and mapping of URLs to routes (URL dispatch or traversal)
95 stars 53 forks source link

Add `dummy_config` pytest fixture. #102

Closed luhn closed 3 years ago

luhn commented 3 years ago

Bringing cookiecutter in line with https://github.com/Pylons/pyramid/pull/3629

I'm leaving app_request as-is for now. I'm not sure where we're leaning with it. @mmerickel, should I bring app_request back to the Pyramid PR?

mmerickel commented 3 years ago

Ok so here's my thinking behind the fixtures, including the improvements in this PR.

So if we add this dummy_config then we basically have two ways of writing tests.

Finally there's app + dummy_request which doesn't entirely work because threadlocals are not pushed as we'd like them to be. Hopefully this is simply discouraged in the dummy_request docstring.

@luhn Can you help improve the cookiecutter with this in mind? Do you have any corrections / improvements you'd like to make to my breakdown / goals?

With respect to app_request not being used anywhere in the default test suite - the entire point of the cookiecutters is to give people good patterns to get started. Just because we aren't using it in the limited tests we ship doesn't mean it's not a good pattern that should remain in the cookiecutter.

I do want to see the fixture get updated to use the context manager so maybe we could add that to this PR:

@pytest.fixture
def app_request(app):
    with prepare(registry=app.registry) as env:
        request = env['request']
        request.host = 'example.com'
        yield request
luhn commented 3 years ago

I think that all makes sense.

I agree keeping app_request, so I'll bring it back to the wiki2 PR.

I'm going to fully root out app + dummy_request, I didn't realize that was still in there.

Beyond that I think the cookiecutter services the goals pretty well. Is there anything else we need in this PR?

stevepiercy commented 3 years ago

BTW, we will be sprinting this weekend, and I can ask newbies to test drive the revised cookiecutter and wiki tutorial, and solicit feedback. Details of the sprint: https://groups.google.com/g/pylons-discuss/c/76p3Amh4F88/m/c9ybcZV2BQAJ

mmerickel commented 3 years ago

Beyond that I think the cookiecutter services the goals pretty well. Is there anything else we need in this PR?

Sounds great to me.

luhn commented 3 years ago

Made the updates, how does that look?

Once approved I'll port it over to wiki2 PR.

mmerickel commented 3 years ago

done, thank you @luhn!