You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The solution is to just add routes in the setUp of your test, but this is not a good idea. I have an email template that is being rendered, and it needs to generate a verification URL to be sent to an end user. The name of that view config is currently 'verify_name'.
So, in my test I'm expected to config.add_route('verify_name', '/verify_name/{token}') so that it will reverse successfully. Problem is, I can misspell the name in one place or the other and my tests will pass, but in production my site fails because my unit test isn't testing my config, its testing a tightly coupled mock config.
My router is intimately coupled to my application and to just leave it out while unit testing is inviting errors. What if I want to return a redirect?
Django doesn't make this kind of mistake, the routes that the app uses are available for "reversing" in Django parlance. Why on earth would Pyramid not have that kind of state available while testing?
The text was updated successfully, but these errors were encountered:
You need to understand the basics of unit testing, and that there are other types of tests.
Unit testing is testing a unit of code, and mocking around it. There are other types of test (e.g. integration tests) that may be more appropriate for some of what you're describing.
Also, in case you're unfamiliar with Github and, you know, people, this is not a place for you to insult a free product and then get free advice from the people who make it.
Go to Stack Overflow and ask your programming question, with a minimal, complete and verifiable example, and do it without complaining that Pyramid isn't Django.
In case someone still faces this problem, I would suggest my solution: in tests that use your app's route URLs, you could use app_request fixture instead of dummy_request. That way you will be testing your actual app with the routes configured for it.
The solution is to just add routes in the setUp of your test, but this is not a good idea. I have an email template that is being rendered, and it needs to generate a verification URL to be sent to an end user. The name of that view config is currently 'verify_name'.
So, in my test I'm expected to
config.add_route('verify_name', '/verify_name/{token}')
so that it will reverse successfully. Problem is, I can misspell the name in one place or the other and my tests will pass, but in production my site fails because my unit test isn't testing my config, its testing a tightly coupled mock config.My router is intimately coupled to my application and to just leave it out while unit testing is inviting errors. What if I want to return a redirect?
Django doesn't make this kind of mistake, the routes that the app uses are available for "reversing" in Django parlance. Why on earth would Pyramid not have that kind of state available while testing?
The text was updated successfully, but these errors were encountered: