Closes #898 (closed)
the initial logic wasn't tested, so I also added some tests.
cc @funkwhale/reviewers-python