Permalink
Browse files

Change position admin tests to not use the db

  • Loading branch information...
1 parent 354820d commit 43810187db9e2afbe0264971f6a109b2b8a2dab3 @HonzaKral HonzaKral committed Feb 21, 2014
Showing with 12 additions and 13 deletions.
  1. +12 −13 test_ella/test_positions/test_admin.py
@@ -1,14 +1,12 @@
# -*- coding: utf-8 -*-
-from test_ella.cases import RedisTestCase as TestCase
+from unittest import TestCase
from nose import tools
-from django.contrib.contenttypes.models import ContentType
from django.contrib import admin
-from test_ella.test_core import create_basic_categories, create_and_place_a_publishable
-
from ella.core.models import Author
+from ella.articles.models import Article
from ella.positions.admin import PositionOptions
from ella.positions.models import Position
@@ -17,20 +15,21 @@ class TestPositionAdmin(TestCase):
def setUp(self):
super(TestPositionAdmin, self).setUp()
- create_basic_categories(self)
- create_and_place_a_publishable(self)
- self.author = Author.objects.create(slug='some-author')
+ self.author = Author(slug='some-author')
self.position_admin = PositionOptions(model=Position, admin_site=admin.site)
def test_result_of_show_title_for_obj_with_title_attr(self):
- p = Position(category=self.category, name='position-name', target_ct=self.publishable.content_type, target_id=self.publishable.pk)
- tools.assert_equals(u'%s [%s]' % (self.publishable.title, self.publishable.content_type.name), self.position_admin.show_title(p))
+ art = Article(title='Hello')
+ p = Position()
+ p.target = art
+ tools.assert_equals(u'Hello [Article]', self.position_admin.show_title(p))
def test_result_of_show_title_for_obj_without_title_attr(self):
- ct = ContentType.objects.get_for_model(Author)
- p = Position(category=self.category, name='position-name', target_ct=ct, target_id=self.author.pk)
- tools.assert_equals(u'%s [%s]' % (self.author, ct.name), self.position_admin.show_title(p))
+ aut = Author(name='Hi!')
+ p = Position()
+ p.target = aut
+ tools.assert_equals(u'Hi! [Author]', self.position_admin.show_title(p))
def test_result_of_show_title_for_position_without_trget(self):
- p = Position(category=self.category, name='position-name')
+ p = Position()
tools.assert_true(self.position_admin.show_title(p).startswith('--'))

0 comments on commit 4381018

Please sign in to comment.