Unit tests: replace mock and compat with code from community.internal_test_tools (#9921)
* Replace compat with equivalent from community.internal_test_tools.
* Replace mock with equivalent from community.internal_test_tools.
(cherry picked from commit 410cf72aec)
Co-authored-by: Felix Fontein <felix@fontein.de>