<s> from django . contrib . contenttypes . models import ContentType <EOL> from nose . tools import eq_ <EOL> from kitsune . access . tests import PermissionFactory <EOL> from kitsune . forums . tests import ForumTestCase , ForumFactory , ThreadFactory , PostFactory <EOL> from kitsune . sumo . tests import get , post <EOL> from kitsune . users . tests import UserFactory , GroupFactory <EOL> class BelongsTestCase ( ForumTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_posts_thread_belongs_to_forum ( self ) : <EOL> """<STR_LIT>""" <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( ) <EOL> r = get ( self . client , '<STR_LIT>' , args = [ f . slug , t . id ] ) <EOL> eq_ ( <NUM_LIT:200> , r . status_code ) <EOL> u = r . redirect_chain [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> assert u . endswith ( t . get_absolute_url ( ) ) <EOL> def test_reply_thread_belongs_to_forum ( self ) : <EOL> """<STR_LIT>""" <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( ) <EOL> u = UserFactory ( ) <EOL> self . client . login ( username = u . username , password = '<STR_LIT>' ) <EOL> r = post ( self . client , '<STR_LIT>' , { } , args = [ f . slug , t . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> def test_locked_thread_belongs_to_forum ( self ) : <EOL> """<STR_LIT>""" <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( ) <EOL> u = UserFactory ( ) <EOL> g = GroupFactory ( ) <EOL> ct = ContentType . objects . get_for_model ( f ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = f . id , group = g ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = t . forum . id , group = g ) <EOL> g . user_set . add ( u ) <EOL> self . client . login ( username = u . username , password = '<STR_LIT>' ) <EOL> r = post ( self . client , '<STR_LIT>' , { } , args = [ f . slug , t . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> def test_sticky_thread_belongs_to_forum ( self ) : <EOL> """<STR_LIT>""" <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( ) <EOL> u = UserFactory ( ) <EOL> g = GroupFactory ( ) <EOL> ct = ContentType . objects . get_for_model ( f ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = f . id , group = g ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = t . forum . id , group = g ) <EOL> g . user_set . add ( u ) <EOL> self . client . login ( username = u . username , password = '<STR_LIT>' ) <EOL> r = post ( self . client , '<STR_LIT>' , { } , args = [ f . slug , t . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> def test_edit_thread_belongs_to_forum ( self ) : <EOL> """<STR_LIT>""" <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( ) <EOL> u = t . creator <EOL> self . client . login ( username = u . username , password = '<STR_LIT>' ) <EOL> r = get ( self . client , '<STR_LIT>' , args = [ f . slug , t . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> def test_delete_thread_belongs_to_forum ( self ) : <EOL> """<STR_LIT>""" <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( ) <EOL> u = UserFactory ( ) <EOL> g = GroupFactory ( ) <EOL> ct = ContentType . objects . get_for_model ( f ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = f . id , group = g ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = t . forum . id , group = g ) <EOL> g . user_set . add ( u ) <EOL> self . client . login ( username = u . username , password = '<STR_LIT>' ) <EOL> r = get ( self . client , '<STR_LIT>' , args = [ f . slug , t . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> def test_edit_post_belongs_to_thread_and_forum ( self ) : <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( forum = f ) <EOL> p = PostFactory ( ) <EOL> u = p . author <EOL> self . client . login ( username = u . username , password = '<STR_LIT>' ) <EOL> r = get ( self . client , '<STR_LIT>' , <EOL> args = [ f . slug , p . thread . id , p . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> r = get ( self . client , '<STR_LIT>' , <EOL> args = [ p . thread . forum . slug , t . id , p . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> def test_delete_post_belongs_to_thread_and_forum ( self ) : <EOL> f = ForumFactory ( ) <EOL> t = ThreadFactory ( forum = f ) <EOL> p = PostFactory ( ) <EOL> u = p . author <EOL> g = GroupFactory ( ) <EOL> ct = ContentType . objects . get_for_model ( f ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = p . thread . forum_id , group = g ) <EOL> PermissionFactory ( codename = '<STR_LIT>' , <EOL> content_type = ct , object_id = f . id , group = g ) <EOL> g . user_set . add ( u ) <EOL> self . client . login ( username = u . username , password = '<STR_LIT>' ) <EOL> r = get ( self . client , '<STR_LIT>' , <EOL> args = [ f . slug , p . thread . id , p . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) <EOL> r = get ( self . client , '<STR_LIT>' , <EOL> args = [ p . thread . forum . slug , t . id , p . id ] ) <EOL> eq_ ( <NUM_LIT> , r . status_code ) </s>
