Пример #1
0
 def setUp(self):
     TestCase.setUp(self)
     self.jane = self.make_user("jane", group='cg_moderator')
     self.bob = self.make_user("bob", group='cg_moderator')
     self.brian = self.make_user("brian", group='cg_moderator')
     self.stacy = self.make_user("stacy")
     self.channel = self.make_channel(self.stacy)
Пример #2
0
    def setUp(self):
        TestCase.setUp(self)
        self.users = [self.make_user('user%i' % i) for i in range(5)]
        self.channels = [self.make_channel(self.users[0], 'A')
                for i in range(10)]
        self.channels.append(self.make_channel(self.users[0], 'U'))

        # subscriptions
        ip0 = '0.0.0.0'
        ip1 = '1.1.1.1'
        ip2 = '2.2.2.2'
        ip3 = '3.3.3.3'
        self.add_multiple_subscriptions(self.channels[0], ip0, ip1, ip2)
        self.add_multiple_subscriptions(self.channels[1], ip1, ip2)
        self.add_multiple_subscriptions(self.channels[2], ip2, ip3)
        self.add_subscription(self.channels[3], ip0)
        self.add_multiple_subscriptions(self.channels[4], ip0, ip1)
        self.add_subscription(self.channels[5], ip1, ignore=True)
        self.add_subscription(self.channels[6], ip1,
            timestamp=datetime.now()-timedelta(days=3))
        self.add_subscription(self.channels[7], ip1,
            timestamp=datetime.now()-timedelta(days=31 * 7))
        self.add_subscription(self.channels[8], ip3)
        self.add_subscription(self.channels[9], ip1,
                timestamp=datetime.now()-timedelta(days=3))
        self.add_multiple_subscriptions(self.channels[10], ip1, ip2)

        # ratings
        self.add_ratings(0, 1, 1, 3, 4, 5)
        self.add_ratings(1, 2, 2, 5, 4, 3)
        self.add_ratings(2, 5, 5, 3, 4)
        self.add_ratings(3, 4, 4, 5, 1, 2)
        self.add_ratings(4, 3, 3, 5, 2, 1)
Пример #3
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('mary')
     self.admin = self.make_user('joe')
     self.admin.is_superuser = True
     self.admin.save()
     self.other_user = self.make_user('bobby', group='cg_moderator')
Пример #4
0
    def setUp(self):
        TestCase.setUp(self)
        self.owner = self.make_user('owner')
        self.owner.get_profile().approved = True
        self.owner.get_profile().save()
        self.channels = []
        for i in range(2):
            channel = self.make_channel(self.owner, state='A')
            channel.name = 'My Channel %i' % i
            channel.save()
            self.channels.append(channel)
        self.categories = categories = []
        self.languages = languages = []
        self.items = []
        for n in range(2):
            cat = Category(name='category%i' % n)
            cat.save()

            lang = Language(name='language%i' % n)
            lang.save()

            item = Item()
            item.channel_id = self.channels[0].id
            item.url = self.channels[0].url + '?item=%i' % n
            item.name = 'item%i' % n
            item.description = 'Item'
            item.size = i
            item.date = datetime.now()
            item.save()
            item.save_thumbnail(
                    file(test_data_path('thumbnail.jpg')))

            categories.append(cat)
            languages.append(lang)
            self.items.append(item)
        self.channels[0].categories.add(*categories)
        self.channels[0].language = languages[0]
        self.channels[0].add_tags(self.owner,
                                  ['tag0', 'tag1'])
        self.channels[0].save_thumbnail(
                file(test_data_path('thumbnail.jpg')))

        self.channels[1].description = 'This is a different description.'
        self.channels[1].save()

        # the order is important because of throttling so we do them in reverse
        # order
        Subscription.objects.add(self.channels[0], '123.123.123.123',
                                 timestamp=datetime.now() - timedelta(days=1))
        Subscription.objects.add(self.channels[0], '123.123.123.123')
        for i in range(5):
            user = self.make_user('foo%i' % i)
            user.get_profile().approved = True
            user.get_profile().save()
            for channel in self.channels:
                rating, _ = Rating.objects.get_or_create(channel=channel,
                                                         user=user)
                rating.rating = i + 1
                rating.save()
Пример #5
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('mary')
     self.admin = self.make_user('joe')
     self.admin.is_superuser = True
     self.admin.save()
     self.other_user = self.make_user('bobby',
                                      group='cg_moderator')
Пример #6
0
    def setUp(self):
        TestCase.setUp(self)
        self.owner = self.make_user('owner')
        self.owner.get_profile().approved = True
        self.owner.get_profile().save()
        self.channels = []
        for i in range(2):
            channel = self.make_channel(self.owner, state='A')
            channel.name = 'My Channel %i' % i
            channel.save()
            self.channels.append(channel)
        self.categories = categories = []
        self.languages = languages = []
        self.items = []
        for n in range(2):
            cat = Category(name='category%i' % n)
            cat.save()

            lang = Language(name='language%i' % n)
            lang.save()

            item = Item()
            item.channel_id = self.channels[0].id
            item.url = self.channels[0].url + '?item=%i' % n
            item.name = 'item%i' % n
            item.description = 'Item'
            item.size = i
            item.date = datetime.now()
            item.save()
            item.save_thumbnail(file(test_data_path('thumbnail.jpg')))

            categories.append(cat)
            languages.append(lang)
            self.items.append(item)
        self.channels[0].categories.add(*categories)
        self.channels[0].language = languages[0]
        self.channels[0].add_tags(self.owner, ['tag0', 'tag1'])
        self.channels[0].save_thumbnail(file(test_data_path('thumbnail.jpg')))

        self.channels[1].description = 'This is a different description.'
        self.channels[1].save()

        # the order is important because of throttling so we do them in reverse
        # order
        Subscription.objects.add(self.channels[0],
                                 '123.123.123.123',
                                 timestamp=datetime.now() - timedelta(days=1))
        Subscription.objects.add(self.channels[0], '123.123.123.123')
        for i in range(5):
            user = self.make_user('foo%i' % i)
            user.get_profile().approved = True
            user.get_profile().save()
            for channel in self.channels:
                rating, _ = Rating.objects.get_or_create(channel=channel,
                                                         user=user)
                rating.rating = i + 1
                rating.save()
Пример #7
0
 def setUp(self):
     TestCase.setUp(self)
     self.ralph = self.make_user('ralph')
     self.channel = self.make_channel(self.ralph)
     self.supermod = self.make_user('supermod',
                                    group=['cg_supermoderator',
                                           'cg_moderator'])
     self.joe = self.make_user('joe', group='cg_moderator')
     self.schmoe = self.make_user('schmoe')
Пример #8
0
 def setUp(self):
     TestCase.setUp(self)
     self.owner = self.make_user('owner')
     self.regular = self.make_user('regular')
     self.regular.get_profile().approved = True
     self.regular.get_profile().save()
     self.mod = self.make_user('mod', group='cg_moderator')
     self.super = self.make_user(
         'super', group=['cg_moderator', 'cg_supermoderator'])
     self.channel = self.make_channel(self.owner, state='A')
Пример #9
0
 def setUp(self):
     TestCase.setUp(self)
     self.owner = self.make_user('owner')
     self.regular = self.make_user('regular')
     self.regular.get_profile().approved = True
     self.regular.get_profile().save()
     self.mod = self.make_user('mod', group='cg_moderator')
     self.super = self.make_user('super', group=['cg_moderator',
                                                 'cg_supermoderator'])
     self.channel = self.make_channel(self.owner, state='A')
Пример #10
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('fred')
     self.moderator = self.make_user('greg', group='cg_moderator')
     self.supermod = self.make_user('henrietta', group=['cg_supermoderator',
                                                        'cg_moderator'])
     self.random_user = self.make_user("jane")
     self.user.email = '*****@*****.**'
     self.user.save()
     self.channel = self.make_channel(self.user)
Пример #11
0
 def setUp(self):
     TestCase.setUp(self)
     self.jane = self.make_user("jane")
     self.jane.is_superuser = True
     self.jane.save()
     self.bob = self.make_user("bob")
     self.cathy = self.make_user("cathy")
     self.adrian = self.make_user("adrian")
     self.judy = self.make_user("judy")
     self.judy.email = '*****@*****.**'
     self.judy.save()
Пример #12
0
 def setUp(self):
     TestCase.setUp(self)
     self.admin = self.make_user('admin')
     self.admin.is_superuser = True
     self.admin.save()
     self.user = self.make_user('user')
     self.plain = self.make_user('plain')
     self.channels = []
     for i in range(3):
         channel = self.make_channel(self.user, state='A')
         self.channels.append(channel)
Пример #13
0
 def setUp(self):
     TestCase.setUp(self)
     self.jane = self.make_user("jane")
     self.jane.is_superuser = True
     self.jane.save()
     self.bob = self.make_user("bob")
     self.cathy = self.make_user("cathy")
     self.adrian = self.make_user("adrian")
     self.judy = self.make_user("judy")
     self.judy.email = '*****@*****.**'
     self.judy.save()
Пример #14
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('user')
     self.mod = self.make_user('mod', group='cg_moderator')
     self.supermod = self.make_user('supermod', group=['cg_moderator',
                                                       'cg_supermoderator'])
     self.new_post_data = {
         'title': 'test title',
         'body': 'test body',
     }
     self.new_post_data_email = self.new_post_data.copy()
     self.new_post_data_email['send-email'] = 1
Пример #15
0
 def setUp(self):
     TestCase.setUp(self)
     self.channel_owner = self.make_user('foobar')
     self.channel_owner.email = '*****@*****.**'
     self.channel_owner.save()
     self.channel = self.make_channel(self.channel_owner)
     self.non_owner = self.make_user('tony')
     self.moderator = self.make_user('greg', group='cg_moderator')
     self.moderator_note = self.make_note('foo')
     self.owner_note = self.make_note('bar')
     self.channel.notes.add(self.moderator_note)
     self.channel.notes.add(self.owner_note)
Пример #16
0
 def setUp(self):
     TestCase.setUp(self)
     self.owner = self.make_user('owner')
     self.owner.get_profile().approved = True
     self.owner.get_profile().save()
     self.channel = self.make_channel(self.owner)
     self.users = []
     for rating in range(6):
         user = self.make_user('user%i' % rating)
         user.get_profile().approved = True
         user.get_profile().save()
         self.users.append(user)
         self.rate_channel(self.channel, user, rating)
     self.logout()
Пример #17
0
 def setUp(self):
     TestCase.setUp(self)
     self.owner = self.make_user('owner')
     self.owner.get_profile().approved = True
     self.owner.get_profile().save()
     self.channel = self.make_channel(self.owner)
     self.users = []
     for rating in range(6):
         user = self.make_user('user%i' % rating)
         user.get_profile().approved = True
         user.get_profile().save()
         self.users.append(user)
         self.rate_channel(self.channel, user, rating)
     self.logout()
Пример #18
0
 def setUp(self):
     TestCase.setUp(self)
     self.change_setting_for_test('MAX_FEATURES', 3)
     self.owner = self.make_user('wanda',
                                 group=['cg_supermoderator'])
     self.channels = [self.make_channel(self.owner, state='A')
             for i in range(8)]
     self.users = [self.make_user('user%i' % i,
                                  group=['cg_supermoderator'])
             for i in range(5)]
     self.old_fq_save = FeaturedQueue.save
     def mockSave(fqself):
         # slow down saves to make distinct timestamps
         self.old_fq_save(fqself)
         time.sleep(1)
     FeaturedQueue.save = mockSave
Пример #19
0
    def setUp(self):
        TestCase.setUp(self)
        self.ralph = self.make_user('ralph')
        self.channel = self.make_channel()
        self.channel.update_items(
            feedparser_input=open(test_data_path('feed.xml')))
        self.channel.name = "Rocketboom"
        self.channel.description = ("Daily with Joanne Colan "
                "(that's right... Joanne Colan")
        self.channel.state = Channel.APPROVED
        self.channel.save()
        ChannelSearchData.objects.update(self.channel)
        # make bogus channels so that the the fulltext indexes work
        for x in range(10):
            c = self.make_channel(state=Channel.APPROVED)
            ChannelSearchData.objects.update(c)

        self.pages = {}
Пример #20
0
    def test_website_url_unique_for_site(self):
        channel = self.make_channel(self.joe)
        channel.url = None
        channel.save()
        mod = self.make_user('moderator', group='cg_moderator')
        TestCase.login(self, mod)
        response = self.post_data('/submit/step1', {'name': 'New Site'})
        self.assertRedirect(response, '/submit/step2')

        response = self.submit(dont_send='url',
                               website_url=channel.website_url)
        self.assertEquals(response.context[0]['form'].errors.keys(),
                          ['website_url'])
        # should work if the other channel is a feed
        channel.url = 'http://www.myblog.com/'
        channel.save()
        response = self.submit(dont_send='url',
                               website_url=channel.website_url)
        self.check_submit_worked(response)
Пример #21
0
    def setUp(self):
        TestCase.setUp(self)
        self.users = [self.make_user('user%i' % i) for i in range(5)]
        self.channels = [
            self.make_channel(self.users[0], 'A') for i in range(10)
        ]
        self.channels.append(self.make_channel(self.users[0], 'U'))

        # subscriptions
        ip0 = '0.0.0.0'
        ip1 = '1.1.1.1'
        ip2 = '2.2.2.2'
        ip3 = '3.3.3.3'
        self.add_multiple_subscriptions(self.channels[0], ip0, ip1, ip2)
        self.add_multiple_subscriptions(self.channels[1], ip1, ip2)
        self.add_multiple_subscriptions(self.channels[2], ip2, ip3)
        self.add_subscription(self.channels[3], ip0)
        self.add_multiple_subscriptions(self.channels[4], ip0, ip1)
        self.add_subscription(self.channels[5], ip1, ignore=True)
        self.add_subscription(self.channels[6],
                              ip1,
                              timestamp=datetime.now() - timedelta(days=3))
        self.add_subscription(self.channels[7],
                              ip1,
                              timestamp=datetime.now() -
                              timedelta(days=31 * 7))
        self.add_subscription(self.channels[8], ip3)
        self.add_subscription(self.channels[9],
                              ip1,
                              timestamp=datetime.now() - timedelta(days=3))
        self.add_multiple_subscriptions(self.channels[10], ip1, ip2)

        # ratings
        self.add_ratings(0, 1, 1, 3, 4, 5)
        self.add_ratings(1, 2, 2, 5, 4, 3)
        self.add_ratings(2, 5, 5, 3, 4)
        self.add_ratings(3, 4, 4, 5, 1, 2)
        self.add_ratings(4, 3, 3, 5, 2, 1)
Пример #22
0
 def setUp(self):
     TestCase.setUp(self)
     self.ralph = self.make_user('ralph')
     self.channel = self.make_channel()
Пример #23
0
 def tearDown(self):
     TestCase.tearDown(self)
     FeaturedQueue.save = self.old_fq_save
     del self.old_fq_save
Пример #24
0
 def setUp(self):
     TestCase.setUp(self)
     self.joe = self.make_user('joe')
     self.cat1 = Category.objects.create(name='foo')
     self.cat2 = Category.objects.create(name='bar')
Пример #25
0
 def setUp(self):
     TestCase.setUp(self)
     self.old_clean = fields.URLField.clean
     fields.URLField.clean = self._patch_urlfield_clean
     owner = self.make_user('owner')
     self.channel = self.make_channel(owner)
Пример #26
0
 def setUp(self):
     TestCase.setUp(self)
     self.old_clean = fields.URLField.clean
     fields.URLField.clean = self._patch_urlfield_clean
     owner = self.make_user('owner')
     self.channel = self.make_channel(owner)
Пример #27
0
 def setUp(self):
     TestCase.setUp(self)
     if self.model is not None:
         self.model_name = self.model._meta.object_name.lower()
Пример #28
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('mary')
Пример #29
0
 def make_channel(self, **kwargs):
     return TestCase.make_channel(self, self.ralph, **kwargs)
Пример #30
0
 def setUp(self):
     TestCase.setUp(self)
     if self.model is not None:
         self.model_name = self.model._meta.object_name.lower()
Пример #31
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('mary')
Пример #32
0
 def setUp(self):
     TestCase.setUp(self)
     self.ralph = self.make_user('ralph')
     self.channel = self.make_channel(self.ralph)
Пример #33
0
 def setUp(self):
     TestCase.setUp(self)
     self.ben = self.make_user('ben')
     self.nick = self.make_user('nick')
     self.channel = self.make_channel(self.ben)
Пример #34
0
 def make_channel(self, **kwargs):
     return TestCase.make_channel(self, self.ralph, **kwargs)
Пример #35
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('mary')
     self.channel = self.make_channel(self.user)
Пример #36
0
 def login(self):
     TestCase.login(self, 'joe')
     return self.get_page('/submit/step1')
Пример #37
0
 def setUp(self):
     TestCase.setUp(self)
     self.user = self.make_user('mary')
     self.channel = self.make_channel(self.user)
Пример #38
0
 def login(self, username):
     TestCase.login(self, username)
     return self.get_page('/moderate')
Пример #39
0
 def setUp(self):
     TestCase.setUp(self)
     owner = self.make_user('owner')
     self.channel = self.make_channel(owner)
Пример #40
0
 def setUp(self):
     TestCase.setUp(self)
     self.ben = self.make_user('ben')
     self.nick = self.make_user('nick')
     self.channel = self.make_channel(self.ben)
Пример #41
0
 def setUp(self):
     TestCase.setUp(self)
     owner = self.make_user('owner')
     self.channel = self.make_channel(owner)