Open FroggyFlox opened 1 year ago
In this case, we fetch system users from: https://github.com/rockstor/rockstor-core/blob/387667dfd393d5c424fd1fa4892e61518cc3b75e/src/rockstor/storageadmin/views/user.py#L151-L152
It is thus proposed that we mock combined_users()
in the test_user.py
test suite.
Note that we likely will also need to mock combined_groups()
as well.
Thanks a lot for remembering and linking to that issue from #2816, @phillxnet, I had completely forgotten.
If my memory is correct on that one, what blocked me at the time was that combined_users()
returns a queryset and I wasn't sure how to mock that properly.
Although we use fixtures to define users used during the
test_user.py
test suite, we fail to properly mock the system users in the same tests. As a result, if the system contains a user with the same name as one defined in the fixture, we encounter conflicts between the two, such as:This happens when the system already has a user named
testuser
. Given our fixture creates a user with the same name but with different attribute, it can lead to errors such as above. See relevant part of the fixture below: https://github.com/rockstor/rockstor-core/blob/387667dfd393d5c424fd1fa4892e61518cc3b75e/src/rockstor/storageadmin/fixtures/test_user.json#L22-L36Reproducer
testuser
poetry run django-admin test -p test_user*