##// END OF EJS Templates
Added post publication date to the templates.
Added post publication date to the templates.

File last commit:

r24:bb515fee default
r26:67f0542d default
Show More
tests.py
101 lines | 2.7 KiB | text/x-python | PythonLexer
Ilyas
Completed login and logout functionality and covered by tests.
r13 from django.utils.unittest import TestCase
from django.test.client import Client
neko259
Partially fixed tests and model definition
r7 import boards
neko259
Initial commit. One test doesn't work, missing posting form.
r0
neko259
Added localization (not fully working). Added tags posting. Changed the design a bit.
r24 from boards.models import Post, Admin, Tag
neko259
Initial commit. One test doesn't work, missing posting form.
r0
neko259
Fixed the tests. Added exists() method for the post.
r8
neko259
Initial commit. One test doesn't work, missing posting form.
r0 class BoardTests(TestCase):
neko259
Added a text area to the posting form. Added a basic CSS style. Changed threads list a bit.
r16 def _create_post(self):
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22 return Post.objects.create_post(title='title',
text='text')
neko259
Initial commit. One test doesn't work, missing posting form.
r0
def test_post_add(self):
neko259
Added a text area to the posting form. Added a basic CSS style. Changed threads list a bit.
r16 post = self._create_post()
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22
neko259
Fixed indents for pycharm. Moved images upload path to settings. Some cosmetic changes.
r1 self.assertIsNotNone(post)
neko259
Partially fixed tests and model definition
r7 self.assertEqual(boards.models.NO_PARENT, post.parent)
neko259
Initial commit. One test doesn't work, missing posting form.
r0
def test_delete_post(self):
neko259
Added a text area to the posting form. Added a basic CSS style. Changed threads list a bit.
r16 post = self._create_post()
neko259
Fixed the tests. Added exists() method for the post.
r8 post_id = post.id
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22
neko259
Fixed indents for pycharm. Moved images upload path to settings. Some cosmetic changes.
r1 Post.objects.delete_post(post)
neko259
Initial commit. One test doesn't work, missing posting form.
r0
neko259
Added a text area to the posting form. Added a basic CSS style. Changed threads list a bit.
r16 self.assertFalse(Post.objects.exists(post_id))
neko259
Initial commit. One test doesn't work, missing posting form.
r0
def test_delete_posts_by_ip(self):
neko259
Added a text area to the posting form. Added a basic CSS style. Changed threads list a bit.
r16 post = self._create_post()
neko259
Fixed the tests. Added exists() method for the post.
r8 post_id = post.id
neko259
Initial commit. One test doesn't work, missing posting form.
r0
neko259
Fixed indents for pycharm. Moved images upload path to settings. Some cosmetic changes.
r1 Post.objects.delete_posts_by_ip('0.0.0.0')
neko259
Initial commit. One test doesn't work, missing posting form.
r0
neko259
Added a text area to the posting form. Added a basic CSS style. Changed threads list a bit.
r16 self.assertFalse(Post.objects.exists(post_id))
Ilyas
Completed login and logout functionality and covered by tests.
r13
# Authentication tests
def _create_test_user(self):
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22 admin = Admin(name='test_username12313584353165',
password='test_userpassword135135512')
Ilyas
Completed login and logout functionality and covered by tests.
r13
admin.save()
return admin
def test_admin_login(self):
client = Client()
self.assertFalse('admin' in client.session)
admin = self._create_test_user()
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22 response = client.post('/login',
{'name': admin.name, 'password': admin.password})
Ilyas
Completed login and logout functionality and covered by tests.
r13
# it means that login passed and user are redirected to another page
self.assertEqual(302, response.status_code)
self.assertTrue('admin' in client.session)
self.assertTrue(client.session['admin'])
admin.delete()
wrong_name = 'sd2f1s3d21fs3d21f'
wrong_password = 'sd2f1s3d21fs3d21fsdfsd'
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22 client.post('/login', {'name': wrong_name, 'password': wrong_password})
Ilyas
Completed login and logout functionality and covered by tests.
r13 self.assertFalse(client.session['admin'])
def test_admin_logout(self):
client = Client()
self.assertFalse('admin' in client.session)
admin = self._create_test_user()
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22 client.post('/login',
{'name': admin.name, 'password': admin.password})
Ilyas
Completed login and logout functionality and covered by tests.
r13
self.assertTrue(client.session['admin'])
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22 client.get('/logout')
Ilyas
Completed login and logout functionality and covered by tests.
r13
self.assertFalse(client.session['admin'])
admin.delete()
neko259
Fixed getting posts for a thread. Implemented thread getting test.
r17 def test_get_thread(self):
opening_post = self._create_post()
op_id = opening_post.id
for i in range(0, 2):
Post.objects.create_post('title', 'text',
neko259
Added images upload. Changed the design a bit. Reformatted some code by PEP 8. Changed the urls: not the main site is located at /, not /boards/.
r22 parent_id=op_id)
neko259
Fixed getting posts for a thread. Implemented thread getting test.
r17
thread = Post.objects.get_thread(op_id)
neko259
Removed call to en internal method in test.
r19 self.assertEqual(3, len(thread))
neko259
Added localization (not fully working). Added tags posting. Changed the design a bit.
r24
def test_create_post_with_tag(self):
tag = Tag.objects.create(name='test_tag')
post = Post.objects.create_post(title='title', text='text', tags=[tag])
self.assertIsNotNone(post)