django-testing

Selenium: Element not clickable … Other Element Would Receive Click

泪湿孤枕 提交于 2021-02-17 18:57:09
问题 When running Selenium tests on my Django project, I've started to get the error: selenium.common.exceptions.WebDriverException: Message: Element is not clickable at point (61, 24.300003051757812). Other element would receive the click: <a class="navbar-brand" href="#"></a> It is odd for two reasons: First, the tests previously passed and I have not edited that part of the code base. Second, when the Selenium-driven Firefox Window pops up and I maximize the page, the tests pass. But when I let

How to pass the user token for API testing in django rest framework?

梦想与她 提交于 2021-02-10 03:26:53
问题 I'm writing some tests to check the connection to my API. I've put in place identification via tokens and I am successful with retrieving a token for a specific test user with : token = Token.objects.get(user__username='testuser') What I'm struggling with is to use that token to create a successful API request as this one : client = APIClient(HTTP_AUTHORIZATION='Token ' + token.key) response = client.get('/patientFull/1/',headers={'Authorization': 'Token ' + token.key}) I have been looking at

How to pass the user token for API testing in django rest framework?

不羁岁月 提交于 2021-02-10 03:21:33
问题 I'm writing some tests to check the connection to my API. I've put in place identification via tokens and I am successful with retrieving a token for a specific test user with : token = Token.objects.get(user__username='testuser') What I'm struggling with is to use that token to create a successful API request as this one : client = APIClient(HTTP_AUTHORIZATION='Token ' + token.key) response = client.get('/patientFull/1/',headers={'Authorization': 'Token ' + token.key}) I have been looking at

How to pass the user token for API testing in django rest framework?

。_饼干妹妹 提交于 2021-02-10 03:19:24
问题 I'm writing some tests to check the connection to my API. I've put in place identification via tokens and I am successful with retrieving a token for a specific test user with : token = Token.objects.get(user__username='testuser') What I'm struggling with is to use that token to create a successful API request as this one : client = APIClient(HTTP_AUTHORIZATION='Token ' + token.key) response = client.get('/patientFull/1/',headers={'Authorization': 'Token ' + token.key}) I have been looking at

How to pass the user token for API testing in django rest framework?

余生长醉 提交于 2021-02-10 03:18:52
问题 I'm writing some tests to check the connection to my API. I've put in place identification via tokens and I am successful with retrieving a token for a specific test user with : token = Token.objects.get(user__username='testuser') What I'm struggling with is to use that token to create a successful API request as this one : client = APIClient(HTTP_AUTHORIZATION='Token ' + token.key) response = client.get('/patientFull/1/',headers={'Authorization': 'Token ' + token.key}) I have been looking at

How to pass the user token for API testing in django rest framework?

∥☆過路亽.° 提交于 2021-02-10 03:18:35
问题 I'm writing some tests to check the connection to my API. I've put in place identification via tokens and I am successful with retrieving a token for a specific test user with : token = Token.objects.get(user__username='testuser') What I'm struggling with is to use that token to create a successful API request as this one : client = APIClient(HTTP_AUTHORIZATION='Token ' + token.key) response = client.get('/patientFull/1/',headers={'Authorization': 'Token ' + token.key}) I have been looking at

How to generate a file upload (test) request with Django REST Framework's APIRequestFactory?

主宰稳场 提交于 2021-01-26 11:08:50
问题 I have developed an API (Python 3.5, Django 1.10, DRF 3.4.2) that uploads a video file to my media path when I request it from my UI. That part is working fine. I try to write a test for this feature but cannot get it to run successfully. #views.py import os from rest_framework import views, parsers, response from django.conf import settings class FileUploadView(views.APIView): parser_classes = (parsers.FileUploadParser,) def put(self, request, filename): file = request.data['file'] handle

How to generate a file upload (test) request with Django REST Framework's APIRequestFactory?

孤街醉人 提交于 2021-01-26 11:06:59
问题 I have developed an API (Python 3.5, Django 1.10, DRF 3.4.2) that uploads a video file to my media path when I request it from my UI. That part is working fine. I try to write a test for this feature but cannot get it to run successfully. #views.py import os from rest_framework import views, parsers, response from django.conf import settings class FileUploadView(views.APIView): parser_classes = (parsers.FileUploadParser,) def put(self, request, filename): file = request.data['file'] handle

How to generate a file upload (test) request with Django REST Framework's APIRequestFactory?

こ雲淡風輕ζ 提交于 2021-01-26 11:05:25
问题 I have developed an API (Python 3.5, Django 1.10, DRF 3.4.2) that uploads a video file to my media path when I request it from my UI. That part is working fine. I try to write a test for this feature but cannot get it to run successfully. #views.py import os from rest_framework import views, parsers, response from django.conf import settings class FileUploadView(views.APIView): parser_classes = (parsers.FileUploadParser,) def put(self, request, filename): file = request.data['file'] handle

Django: is there a way to count SQL queries from an unit test?

纵然是瞬间 提交于 2020-07-16 16:24:52
问题 I am trying to find out the number of queries executed by a utility function. I have written a unit test for this function and the function is working well. What I would like to do is track the number of SQL queries executed by the function so that I can see if there is any improvement after some refactoring. def do_something_in_the_database(): # Does something in the database # return result class DoSomethingTests(django.test.TestCase): def test_function_returns_correct_values(self): self