conference подготовлено для написания тестов

remotes/origin/tests
avgoeid 9 years ago
parent 67439690a2
commit fae73f6af4
  1. 0
      apps/__init__.py
  2. 7
      apps/conference/models.py
  3. 16
      apps/conference/tests.py
  4. 1
      apps/conference/tests/__init__.py
  5. 75
      apps/conference/tests/test_models.py
  6. 2
      apps/events/models.py
  7. 6
      proj/settings.py

@ -83,7 +83,7 @@ class Conference(TranslatableModel, EventMixin, ExpoMixin):
periodic_once = models.CharField(verbose_name=_(u'Проводится в n-й раз'), help_text=_(u'10'), max_length=10, blank=True, null=True) periodic_once = models.CharField(verbose_name=_(u'Проводится в n-й раз'), help_text=_(u'10'), max_length=10, blank=True, null=True)
periodic = models.FloatField(verbose_name=_(u'Переодичность'), blank=True, null=True) periodic = models.FloatField(verbose_name=_(u'Переодичность'), blank=True, null=True)
audience = models.ManyToManyField(TargetAudience, null=True) audience = BitField(flags=[k for k, v in BIT_AUDIENCE])
web_page = models.CharField(verbose_name=_(u'Вебсайт'), max_length=255, blank=True) web_page = models.CharField(verbose_name=_(u'Вебсайт'), max_length=255, blank=True)
link = models.CharField(verbose_name=_(u'Линк на регистрацию'), max_length=255, blank=True) link = models.CharField(verbose_name=_(u'Линк на регистрацию'), max_length=255, blank=True)
programm_link = models.URLField(verbose_name=_(u'Программа конференции'), max_length=255, blank=True) programm_link = models.URLField(verbose_name=_(u'Программа конференции'), max_length=255, blank=True)
@ -115,7 +115,7 @@ class Conference(TranslatableModel, EventMixin, ExpoMixin):
#translated fields #translated fields
translations = TranslatedFields( translations = TranslatedFields(
name = models.CharField(verbose_name=_(u'Название'), max_length=255), name=models.CharField(verbose_name=_(u'Название'), max_length=255),
main_title=models.TextField(verbose_name=_(u'Краткое описание'), blank=True), main_title=models.TextField(verbose_name=_(u'Краткое описание'), blank=True),
description=models.TextField(verbose_name=_(u'Описание'), blank=True), description=models.TextField(verbose_name=_(u'Описание'), blank=True),
main_themes=models.TextField(verbose_name=_(u'Основные темы'), blank=True), main_themes=models.TextField(verbose_name=_(u'Основные темы'), blank=True),
@ -186,7 +186,8 @@ class Conference(TranslatableModel, EventMixin, ExpoMixin):
return '/conference/' return '/conference/'
def get_audience(self): def get_audience(self):
checked = [item for item, bool in self.audience if bool==True] print self.audience.all()
checked = [item for item, bool in self.audience if bool]
audience = [] audience = []
for k, v in BIT_AUDIENCE: for k, v in BIT_AUDIENCE:
for item in checked: for item in checked:

@ -1,16 +0,0 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)

@ -0,0 +1 @@
from .test_models import *

@ -0,0 +1,75 @@
import datetime
from django.test import TestCase
from ..models import Conference, Speaker
from city.models import City
from country.models import Country
from events.models import TargetAudience
class ConferenceTest(TestCase):
def setUp(self):
self.conference = Conference.objects.create(
name='New Conference',
data_begin=datetime.datetime.now(),
data_end=datetime.timedelta(24)+datetime.datetime.now(),
country=Country.objects.all()[0],
city=City.objects.all()[0],
url='new-conference',
audience=0
)
def test_a_conference_create(self):
conference_count = Conference.objects.all().count()
Conference.objects.create(
name='New Conference',
data_begin=datetime.datetime.now(),
data_end=datetime.timedelta(24)+datetime.datetime.now(),
country=Country.objects.all()[0],
city=City.objects.all()[0]
)
new_conference_count = Conference.objects.all().count()
self.assertEqual(conference_count + 1, new_conference_count)
def test_save_conference_info(self):
name = 'New Conference'
datetime_now = datetime.datetime.now()
data_begin = datetime_now
data_end = datetime.timedelta(24) + datetime_now
country = Country.objects.all()[0]
city = City.objects.all()[0]
new_conference = Conference.objects.create(
name=name,
data_begin=data_begin,
data_end=data_end,
country=country,
city=city
)
self.assertEqual(name, new_conference.name)
self.assertEqual(data_begin, new_conference.data_begin)
self.assertEqual(data_end, new_conference.data_end)
self.assertEqual(country, new_conference.country)
self.assertEqual(city, new_conference.city)
def test_method_get_services(self):
pass
def test_method_get_news_url(self):
self.assertEqual(
'%s' % self.conference.get_news_url(),
'/news/conference/%s/' % self.conference.url
)
def test_method_get_audience(self):
self.assertEqual(self.conference.get_audience(), '')
class SpeakerTest(TestCase):
pass

@ -10,4 +10,4 @@ class TargetAudience(models.Model):
title = models.CharField(_(u'Название'), max_length=200) title = models.CharField(_(u'Название'), max_length=200)
def __unicode__(self): def __unicode__(self):
return unicode(self.title) return unicode(self.title)

@ -2,10 +2,10 @@
# Django settings for proj project. # Django settings for proj project.
import os import os
import sys import sys
import django
from django.utils.translation import ugettext_lazy as _
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
import django
from django.utils.translation import ugettext_lazy as _
DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__)) DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))
SITE_ROOT = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] SITE_ROOT = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
@ -531,7 +531,7 @@ PERIODIC = {
# } # }
try: try:
from local import * from proj.local import *
except ImportError, e: except ImportError, e:
pass pass

Loading…
Cancel
Save