-
Notifications
You must be signed in to change notification settings - Fork 963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock the database in the unit test suite #77
Comments
A potentially simpler approach is to use an in-memory sqlite database for |
I don't plan on keeping compatibility with SQLite. Right now there is but once PyPI legacy is gone and I can modify the schema I plan to take advantage of PostgreSQL's advanced capabilities. This is just for the unit tests though, the functional tests (which will test high level features/user stories) will still be required to be backed by a real database. |
I suspect (but can't prove) that an sqlite compatible subset of the schema |
Possibly. I'm not worried about the speed of PostgreSQL mostly that it's annoying to have to type out the command. If I can't mock it then I'll probably just leave it as is. |
Not mocks, fakes! Verified fakes ideally :) /cc @dreid On Sun, Oct 20, 2013 at 3:08 PM, Donald Stufft [email protected]:
"I disapprove of what you say, but I will defend to the death your right to |
Well I'd want to verify that the method is calling the execute method with a particular query, so that would be a mock would it not? |
Oh, if your'e going to do it that way, then yes it's a mock. I think having On Sun, Oct 20, 2013 at 3:35 PM, Donald Stufft [email protected]:
"I disapprove of what you say, but I will defend to the death your right to |
Hmm, well I have functions like this: https://github.com/dstufft/warehouse/blob/master/warehouse/packaging/models.py#L35-L39 And I need to test them, currently I test them by starting a transaction, filling in some data, testing the return of that function, then rolling back the transaction. My thought was to just replace the execute function with a Mock and verify that the query matches. How would your way work? |
Basically you replace the models layer with a fake object that just keeps On Sun, Oct 20, 2013 at 3:37 PM, Donald Stufft [email protected]:
"I disapprove of what you say, but I will defend to the death your right to |
But how do I test the models layer itself? |
I'm already stubbing out the models layer outside of tests of the model layer. |
Ah, I'd test the models layer against the real DB; if you do anything Alex On Sun, Oct 20, 2013 at 3:38 PM, Donald Stufft [email protected]:
"I disapprove of what you say, but I will defend to the death your right to |
Hrm, I suppose complex queries would be a problem :/ |
Ok i've been sufficiently convinced. |
No description provided.
The text was updated successfully, but these errors were encountered: