예제 #1
0
    def test_published(self):
        """ユーザーが閲覧可能なスターの一覧を返す"""
        article1 = self.articles['public']
        article2 = self.articles['protected']
        article3 = self.articles['draft']
        users = create_role_users()

        for i in range(1):
            StarFactory(content_object=article1)
        for i in range(2):
            StarFactory(content_object=article2)
        for i in range(3):
            StarFactory(content_object=article3)

        patterns = (
            ('adam', 3),
            ('seele', 3),
            ('nerv', 3),
            ('children', 3),
            ('wille', 1),
            ('anonymous', 1),
        )
        for role, nstars in patterns:
            qs = Star.objects.published(users[role])
            self.assertEqual(qs.count(), nstars,
                             "{} should see {} stars".format(role, nstars))
예제 #2
0
 def setUp(self):
     self.announcements = dict(
         public=AnnouncementFactory(pub_state='public'),
         protected=AnnouncementFactory(pub_state='protected'),
         draft=AnnouncementFactory(pub_state='draft'),
     )
     self.users = create_role_users()
예제 #3
0
    def test_published(self):
        """ユーザーが閲覧可能なスターの一覧を返す"""
        article1 = self.articles['public']
        article2 = self.articles['protected']
        article3 = self.articles['draft']
        users = create_role_users()

        for i in range(1):
            StarFactory(content_object=article1)
        for i in range(2):
            StarFactory(content_object=article2)
        for i in range(3):
            StarFactory(content_object=article3)

        patterns = (
            ('adam', 3),
            ('seele', 3),
            ('nerv', 3),
            ('children', 3),
            ('wille', 1),
            ('anonymous', 1),
        )
        for role, nstars in patterns:
            qs = Star.objects.published(users[role])
            self.assertEqual(qs.count(), nstars,
                             "{} should see {} stars".format(role, nstars))
예제 #4
0
 def setUp(self):
     self.announcements = dict(
         public=AnnouncementFactory(pub_state='public'),
         protected=AnnouncementFactory(pub_state='protected'),
         draft=AnnouncementFactory(pub_state='draft'),
     )
     self.users = create_role_users()
예제 #5
0
 def setUp(self):
     self.author = PersonaFactory(username='******', role='children')
     self.users = create_role_users({'author': self.author})
     self.entries = dict(
         public=EntryFactory(pub_state='public'),
         protected=EntryFactory(pub_state='protected'),
         draft=EntryFactory(pub_state='draft', author=self.author),
     )
예제 #6
0
 def setUp(self):
     self.author = PersonaFactory(username='******', role='children')
     self.users = create_role_users({'author': self.author})
     self.entries = dict(
         public=EntryFactory(pub_state='public'),
         protected=EntryFactory(pub_state='protected'),
         draft=EntryFactory(pub_state='draft', author=self.author),
     )
예제 #7
0
 def setUp(self):
     self.administrator = PersonaFactory(username='******',
                                         role='children')
     self.users = create_role_users({'administrator': self.administrator})
     self.projects = (
         ProjectFactory(pub_state='public'),
         ProjectFactory(pub_state='public'),
         ProjectFactory(pub_state='public', status='eternal'),
         ProjectFactory(pub_state='protected'),
         ProjectFactory(pub_state='protected', status='eternal'),
         ProjectFactory(pub_state='draft',
                        administrator=self.administrator),
     )
예제 #8
0
 def setUp(self):
     self.administrator = PersonaFactory(username='******',
                                         role='children')
     self.users = create_role_users({'administrator': self.administrator})
     self.projects = (
         ProjectFactory(pub_state='public'),
         ProjectFactory(pub_state='public'),
         ProjectFactory(pub_state='public', status='eternal'),
         ProjectFactory(pub_state='protected'),
         ProjectFactory(pub_state='protected', status='eternal'),
         ProjectFactory(pub_state='draft',
                        administrator=self.administrator),
     )
예제 #9
0
 def setUp(self):
     self.author = PersonaFactory(username='******', role='children')
     self.users = create_role_users({'author': self.author})
     self.articles = dict(
         public=Article.objects.create(title="public",
                                       author=self.users['author'],
                                       pub_state='public'),
         protected=Article.objects.create(title="protected",
                                          author=self.users['author'],
                                          pub_state='protected'),
         draft=Article.objects.create(title="draft",
                                      author=self.users['author'],
                                      pub_state='draft'),
     )
예제 #10
0
 def setUp(self):
     self.users = create_role_users()
     self.articles = dict(
         public=ArticleFactory(pub_state='public'),
         protected=ArticleFactory(pub_state='protected'),
         draft=ArticleFactory(pub_state='draft'),
     )
     self.stars = (
         StarFactory(content_object=self.articles['public']),
         StarFactory(content_object=self.articles['public']),
         StarFactory(content_object=self.articles['public']),
         StarFactory(content_object=self.articles['protected']),
         StarFactory(content_object=self.articles['protected']),
         StarFactory(content_object=self.articles['draft']),
     )
예제 #11
0
 def setUp(self):
     self.users = create_role_users()
     self.articles = dict(
         public=ArticleFactory(pub_state='public'),
         protected=ArticleFactory(pub_state='protected'),
         draft=ArticleFactory(pub_state='draft'),
     )
     self.stars = (
         StarFactory(content_object=self.articles['public']),
         StarFactory(content_object=self.articles['public']),
         StarFactory(content_object=self.articles['public']),
         StarFactory(content_object=self.articles['protected']),
         StarFactory(content_object=self.articles['protected']),
         StarFactory(content_object=self.articles['draft']),
     )
예제 #12
0
    def setUp(self):
        seven_days_ago = timezone.now() - timezone.timedelta(days=7, hours=1)
        self.announcements = dict(
            public=AnnouncementFactory(pub_state='public'),
            protected=AnnouncementFactory(pub_state='protected'),
            draft=AnnouncementFactory(pub_state='draft'),
            old_public=AnnouncementFactory(pub_state='public',
                                           created_at=seven_days_ago),
            old_protected=AnnouncementFactory(pub_state='protected',
                                              created_at=seven_days_ago),
            old_draft=AnnouncementFactory(pub_state='draft',
                                          created_at=seven_days_ago),
        )
        # ここで上書きしないとダメっぽい
        self.announcements['old_public'].created_at = seven_days_ago
        self.announcements['old_public'].save()
        self.announcements['old_protected'].created_at = seven_days_ago
        self.announcements['old_protected'].save()
        self.announcements['old_draft'].created_at = seven_days_ago
        self.announcements['old_draft'].save()

        self.users = create_role_users()
예제 #13
0
    def setUp(self):
        seven_days_ago = timezone.now() - timezone.timedelta(days=7, hours=1)
        self.announcements = dict(
            public=AnnouncementFactory(pub_state='public'),
            protected=AnnouncementFactory(pub_state='protected'),
            draft=AnnouncementFactory(pub_state='draft'),
            old_public=AnnouncementFactory(pub_state='public',
                                           created_at=seven_days_ago),
            old_protected=AnnouncementFactory(pub_state='protected',
                                              created_at=seven_days_ago),
            old_draft=AnnouncementFactory(pub_state='draft',
                                          created_at=seven_days_ago),
        )
        # ここで上書きしないとダメっぽい
        self.announcements['old_public'].created_at = seven_days_ago
        self.announcements['old_public'].save()
        self.announcements['old_protected'].created_at = seven_days_ago
        self.announcements['old_protected'].save()
        self.announcements['old_draft'].created_at = seven_days_ago
        self.announcements['old_draft'].save()

        self.users = create_role_users()
예제 #14
0
 def setUp(self):
     # イベントリストの作成
     arguments_list = (
         (-3, 0),                                # 2000/9/1-4    Almost
         (-2, -1),                               # 2000/9/2-3    Finish
         (4, 5),                                 # 2000/9/8-9
         (5, 6, {'pub_state': 'draft'}),         # 2000/9/9-10
         (0, 3, {'pub_state': 'protected'}),     # 2000/9/4-7
         (5, 6, {'number_restriction': 1}),      # number restricted
         (5, 6,),                                # deadline
     )
     self.event_list = [event_factory_with_relative(*args)
                        for args in arguments_list]
     # 過去のイベントが作れない制約を回避するために現在時間をモックで変更
     standard_time = static_now()
     attendance_deadline = standard_time - datetime.timedelta(hours=24)
     static_now_past = lambda: static_now() - datetime.timedelta(hours=48)
     with mock.patch('django.utils.timezone.now', static_now_past):
         self.event_list[-1].attendance_deadline = attendance_deadline
         self.event_list[-1].save()
     # draft 記事の作成者を取得
     self.organizer = self.event_list[3].organizer
     self.users = create_role_users({'organizer': self.organizer})