def property_hourly(db): prop_obj = PropertyFactory(booking_type=200, price=None) client = APIClient() owner = UserFactory() refresh = RefreshToken.for_user(owner) client.credentials( HTTP_AUTHORIZATION=f'Bearer {str(refresh.access_token)}') OwnershipFactory(premises=prop_obj, permission_level_id=400, user=owner, is_creator=True, can_edit=True, can_delete=True, can_add_images=True, can_delete_images=True, can_add_bookings=True, can_manage_bookings=True, can_add_owners=True, can_manage_owners=True, can_delete_owners=True, can_add_locks=True, can_manage_locks=True, can_delete_locks=True, can_add_to_group=True, can_add_to_organisation=True, is_super_owner=True) return prop_obj, owner, client
def property_daily_for_booking(db): prop_obj = PropertyFactory(booking_type=100, price=None) client = APIClient() owner = UserFactory() refresh = RefreshToken.for_user(owner) client.credentials( HTTP_AUTHORIZATION=f'Bearer {str(refresh.access_token)}') OwnershipFactory(premises=prop_obj, permission_level_id=400, user=owner, is_creator=True, can_edit=True, can_delete=True, can_add_images=True, can_delete_images=True, can_add_bookings=True, can_manage_bookings=True, can_add_owners=True, can_manage_owners=True, can_delete_owners=True, can_add_locks=True, can_manage_locks=True, can_delete_locks=True, can_add_to_group=True, can_add_to_organisation=True, is_super_owner=True) PropertyAvailabilityFactory(premises=prop_obj, open_days='1111100', available_from=time(hour=14, minute=0), available_until=time(hour=11, minute=0), maximum_number_of_clients=5) return prop_obj, owner, client
def get(self): client = APIClient() user = UserFactory() refresh = RefreshToken.for_user(user) client.credentials( HTTP_AUTHORIZATION=f'Bearer {str(refresh.access_token)}') return client
def test_check_health(self): user = UserFactory() client = APIClient() _url = reverse('jwtauth:token_obtain_pair') _json = {"email": user.email, "password": "******"} for i in range(0, 5): client.post(_url, data=_json, format='json') # this call should err response = client.post(_url, data=_json, format='json') # 429 - too many requests self.assertEqual(response.status_code, 429)