refactor: replace some create_user with UserFactory to avoid non-existent profile errors

This commit is contained in:
Maria Grimaldi
2021-08-23 17:55:03 -04:00
parent b7dfaa9b17
commit 2ee52ea96c
24 changed files with 142 additions and 86 deletions

View File

@@ -10,7 +10,6 @@ from uuid import uuid4
import ddt
from boto.exception import NoAuthHandlerFound
from django.conf import settings
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.core import mail
from django.test import override_settings
from django.urls import reverse
@@ -20,6 +19,7 @@ from user_tasks.models import UserTaskArtifact, UserTaskStatus
from user_tasks.serializers import ArtifactSerializer, StatusSerializer
from cms.djangoapps.contentstore.toggles import BYPASS_OLX_FAILURE
from common.djangoapps.student.tests.factories import UserFactory
from .signals import user_task_stopped
@@ -78,7 +78,7 @@ class TestUserTasks(APITestCase):
@classmethod
def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called
cls.user = User.objects.create_user('test_user', 'test@example.com', 'password')
cls.user = UserFactory.create(username='test_user', email='test@example.com', password='password')
cls.status = UserTaskStatus.objects.create(
user=cls.user, task_id=str(uuid4()), task_class='test_rest_api.sample_task', name='SampleTask 2',
total_steps=5)
@@ -152,7 +152,7 @@ class TestUserTaskStopped(APITestCase):
@classmethod
def setUpTestData(cls): # lint-amnesty, pylint: disable=super-method-not-called
cls.user = User.objects.create_user('test_user', 'test@example.com', 'password')
cls.user = UserFactory.create(username='test_user', email='test@example.com', password='password')
cls.status = UserTaskStatus.objects.create(
user=cls.user, task_id=str(uuid4()), task_class='test_rest_api.sample_task', name='SampleTask 2',
total_steps=5)