def test_active(self):
        self.F.ApiKeyFactory.create(active=False)
        k = self.F.ApiKeyFactory.create(active=True)

        self.assertEqual(list(self.model.ApiKey.objects.active()), [k])
Manager has method to return active keys only.
dataset/ETHPy150Open mozilla/moztrap/tests/model/core/models/test_apikey.py/ApiKeyTest.test_active