Closed phillxnet closed 7 months ago
Do you want to programmatically resolve this? Or is this something that should be mentioned in the contribution documentation only?
I would favor the former, personally. Our tests should be able to pass whatever the host system's current state so it means we're missing a mock somewhere, most likely.
In that case, is it better to just use a very unique user name, or should it be a two-step process, whereas there is an attempt to delete a user by the name of "testuser" before creating one (i.e. that test case)? And maybe a third step where that created test user is being destroyed again before the test cycle is over? So something like running in sequence the existing test cases?
1) something like the method test_delete_existing_user(self)
- since this step is only for cleanup in case testuser
already exists, it would not be considered a failure
2) test_post_requests(self)
3) test_delete_existing_user(self)
Or could the testuser
be changed to one that e.g. is a combination of testuser
appended with a randomly generated number (That has probably some implications that would require other test cases to be adjusted that use testuser
currently?
Ideally we shouldn't need to do any of that and the test in itself should be isolated enough to be robust against this sort of things.
Now, it seems that the failing test show was the following symptom: the POST
request to create a user with an already used uid
does not fail while it should.
The test is already using fixtures properly, but I noticed that these uid/good in the fixture are int
... maybe we now need to recreate that fixture or simply convert these to str
... if that's the case, there may be even more implications but we'll need to see that fixture "issue" first.
It could also be the consequence of the previous POST calls in that same test but it needs more exploration here.
@FroggyFlox I've just notice you already reported this exact same issue; so closing this as a duplicate thus:
Duplicate of #2647
See: "Insufficient mocking in test_user.py" #2647
When running our tests on a system with an existing user named
testuser
, we see an unintended host sensitivity to this user existing:With the removal of this user thus:
Resulting in all tests then passing again: