def test_cleanupcas_management_command_chain(self):
        """
        The ``cleanupcas`` management command should delete chains of
        invalid tickets.
        """
        st = ConsumedServiceTicketFactory()
        pgt = ExpiredProxyGrantingTicketFactory(expires=now() - timedelta(seconds=5),
                                                granted_by_st=st)
        pt = ConsumedProxyTicketFactory(granted_by_pgt=pgt)
        pgt2 = ExpiredProxyGrantingTicketFactory(granted_by_st=None,
                                                 granted_by_pt=pt)
        ConsumedProxyTicketFactory(granted_by_pgt=pgt2)
        management.call_command('cleanupcas')

        self.assertEqual(ServiceTicket.objects.count(), 0)
        self.assertEqual(ProxyGrantingTicket.objects.count(), 0)
        self.assertEqual(ProxyTicket.objects.count(), 0)
dataset/ETHPy150Open jbittel/django-mama-cas/mama_cas/tests/test_models.py/ManagementCommandTests.test_cleanupcas_management_command_chain/original