From 597d6e8fb631a18b8b2dcc75e7c6966e73819416 Mon Sep 17 00:00:00 2001 From: Sean Hayes Date: Mon, 25 Jan 2016 13:58:07 -0800 Subject: [PATCH] Cleaned up hard coded User model. --- django_mesh/tests/test_managers.py | 8 +++----- django_mesh/tests/util.py | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/django_mesh/tests/test_managers.py b/django_mesh/tests/test_managers.py index a472cfb..d9417ab 100644 --- a/django_mesh/tests/test_managers.py +++ b/django_mesh/tests/test_managers.py @@ -20,7 +20,6 @@ # Test imports from .util import BaseTestCase -from django.contrib.auth import get_user_model class PostQuerySetTestCase(BaseTestCase): def test_active(self): @@ -267,9 +266,8 @@ def test_only_published_posts_shows_up(self): self.assertNotIn(self.t2, viewable) def test_tags_only_show_up_if_user_has_access_to_that_Channel(self): + user = self.user - new_user = get_user_model() - new_user.id = 1 self.c1.save() self.c3.save() # user does not have access to this channel @@ -285,7 +283,7 @@ def test_tags_only_show_up_if_user_has_access_to_that_Channel(self): self.p1.tags.add(self.t1) self.p2.tags.add(self.t2) - viewable = Tag.objects.get_for_user(new_user) + viewable = Tag.objects.get_for_user(user) self.assertIn(self.t1, viewable) - self.assertNotIn(self.t2, viewable) \ No newline at end of file + self.assertNotIn(self.t2, viewable) diff --git a/django_mesh/tests/util.py b/django_mesh/tests/util.py index f3cedbe..b7f71f3 100644 --- a/django_mesh/tests/util.py +++ b/django_mesh/tests/util.py @@ -20,7 +20,7 @@ #Django imports from django.test import TestCase -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.contrib.sites.models import Site from django.core.cache import cache from django.utils import timezone @@ -29,6 +29,10 @@ from .. import models from ..models import Channel, Post, Tag + +User = get_user_model() + + class BaseTestCase(TestCase): def setUp(self):