Esempio n. 1
0
 def test_list(self, api_client):
     """List plans"""
     size = 10
     PlanFactory.create_batch(size)
     response = api_client.get(f"/pp-api/plans/")
     assert response.status_code == status.HTTP_200_OK
     response_json = json.loads(response.content)
     assert len(
         response_json["results"]) == Plan.objects.get_public().count()
     assert "id" in response_json["results"][0]
Esempio n. 2
0
    def test_list_filter_by_account(self, api_client):
        """List plans by stripe account"""
        size = 2
        PlanFactory.create_batch(size, stripe_account=StripeAccounts.muckrock)
        PlanFactory.create_batch(size, stripe_account=StripeAccounts.presspass)

        for account in [StripeAccounts.muckrock, StripeAccounts.presspass]:
            response = api_client.get(f"/pp-api/plans/", {"account": account})
            assert response.status_code == status.HTTP_200_OK
            response_json = json.loads(response.content)
            assert (len(
                response_json["results"]) == Plan.objects.get_public().filter(
                    stripe_account=account).count())

        response = api_client.get(f"/pp-api/plans/")
        assert response.status_code == status.HTTP_200_OK
        response_json = json.loads(response.content)
        assert len(
            response_json["results"]) == Plan.objects.get_public().count()