<s> from django . contrib . sites . models import Site <EOL> from django . test import TestCase <EOL> from planet . tests . factories import AuthorFactory , FeedFactory , PostFactory , SiteFactory <EOL> from planet . models import Blog , Feed , Post , Author <EOL> class ManagersTestCase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . author1 = AuthorFactory . create ( ) <EOL> self . author2 = AuthorFactory . create ( ) <EOL> self . other_site = SiteFactory . create ( ) <EOL> self . other_feed = FeedFactory . create ( site = self . other_site ) <EOL> self . other_posts = PostFactory . create_batch ( size = <NUM_LIT:4> , feed = self . other_feed , authors = [ self . author1 ] ) <EOL> self . my_site = Site . objects . get ( pk = <NUM_LIT:1> ) <EOL> self . my_feed = FeedFactory . create ( site = self . my_site ) <EOL> self . site_posts = PostFactory . create_batch ( size = <NUM_LIT:5> , feed = self . my_feed , authors = [ self . author2 ] ) <EOL> def test_posts ( self ) : <EOL> self . assertEqual ( Post . objects . count ( ) , <NUM_LIT:9> ) <EOL> self . assertEqual ( Post . site_objects . count ( ) , <NUM_LIT:5> ) <EOL> site_posts_qs = Post . site_objects . all ( ) <EOL> for post in self . site_posts : <EOL> self . assertTrue ( post in site_posts_qs ) <EOL> def test_feeds ( self ) : <EOL> self . assertEqual ( Feed . objects . count ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( Feed . site_objects . count ( ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( self . my_feed in Feed . site_objects . all ( ) ) <EOL> def test_blogs ( self ) : <EOL> self . assertEqual ( Blog . objects . count ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( Blog . site_objects . count ( ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( self . my_feed . blog in Blog . site_objects . all ( ) ) <EOL> def test_author_count ( self ) : <EOL> self . assertEqual ( Author . objects . count ( ) , <NUM_LIT:2> ) <EOL> def test_author_posts_counts ( self ) : <EOL> self . assertEqual ( Post . objects . filter ( authors = self . author1 ) . count ( ) , <NUM_LIT:4> ) <EOL> self . assertEqual ( Post . objects . filter ( authors = self . author2 ) . count ( ) , <NUM_LIT:5> ) </s>
