Ejemplo n.º 1
0
    def setUp(self):
        super(TestActivePostersRanking, self).setUp()

        cache.clear()
        threadstore.clear()

        self.category = Category.objects.get(slug='first-category')
Ejemplo n.º 2
0
    def setUp(self):
        cache.cache.clear()
        threadstore.clear()

        self.user = UserModel.objects.create_user("UserA", "*****@*****.**",
                                                  'Pass.123')
        self.category = Category.objects.get(slug='first-category')
Ejemplo n.º 3
0
    def setUp(self):
        super(CategoriesUtilsTests, self).setUp()
        threadstore.clear()

        self.root = Category.objects.root_category()
        self.first_category = Category.objects.get(slug='first-category')
        """
        Create categories tree for test cases:

        First category (created by migration)

        Category A
          + Category B
            + Subcategory C
            + Subcategory D

        Category E
          + Subcategory F
        """
        Category(
            name='Category A',
            slug='category-a',
        ).insert_at(self.root, position='last-child', save=True)
        Category(
            name='Category E',
            slug='category-e',
        ).insert_at(self.root, position='last-child', save=True)

        self.category_a = Category.objects.get(slug='category-a')

        Category(
            name='Category B',
            slug='category-b',
        ).insert_at(self.category_a, position='last-child', save=True)

        self.category_b = Category.objects.get(slug='category-b')

        Category(
            name='Subcategory C',
            slug='subcategory-c',
        ).insert_at(self.category_b, position='last-child', save=True)
        Category(
            name='Subcategory D',
            slug='subcategory-d',
        ).insert_at(self.category_b, position='last-child', save=True)

        self.category_e = Category.objects.get(slug='category-e')
        Category(
            name='Subcategory F',
            slug='subcategory-f',
        ).insert_at(self.category_e, position='last-child', save=True)

        categories_acl = {'categories': {}, 'visible_categories': []}
        for category in Category.objects.all_categories():
            categories_acl['visible_categories'].append(category.pk)
            categories_acl['categories'][category.pk] = {
                'can_see': 1,
                'can_browse': 1
            }
        override_acl(self.user, categories_acl)
Ejemplo n.º 4
0
    def setUp(self):
        super(TestActivePostersRanking, self).setUp()

        cache.clear()
        threadstore.clear()

        self.category = Category.objects.all_categories()[:1][0]
    def setUp(self):
        super().setUp()

        cache.clear()
        threadstore.clear()

        self.category = Category.objects.get(slug='first-category')
Ejemplo n.º 6
0
 def test_clear_store(self):
     """clear cleared threadstore"""
     self.assertEqual(threadstore.get('the_fish'), None)
     threadstore.set('the_fish', 'Eric')
     self.assertEqual(threadstore.get('the_fish'), 'Eric')
     threadstore.clear()
     self.assertEqual(threadstore.get('the_fish'), None)
    def setUp(self):
        super(TestActivePostersRanking, self).setUp()

        cache.clear()
        threadstore.clear()

        self.category = Category.objects.get(slug='first-category')
Ejemplo n.º 8
0
    def setUp(self):
        super(ActivePostersListTests, self).setUp()
        self.link = '/api/users/?list=active'

        cache.clear()
        threadstore.clear()

        self.category = Category.objects.all_categories()[:1][0]
        self.category.labels = []
Ejemplo n.º 9
0
    def setUp(self):
        super(ActiveUsersListTests, self).setUp()
        self.link = '/api/users/?list=active'

        cache.clear()
        threadstore.clear()

        self.forum = Forum.objects.all_forums().filter(role="forum")[:1][0]
        self.forum.labels = []
Ejemplo n.º 10
0
    def setUp(self):
        super(ActivePostersListTests, self).setUp()
        self.link = '/api/users/?list=active'

        cache.clear()
        threadstore.clear()

        self.category = Category.objects.all_categories()[:1][0]
        self.category.labels = []
Ejemplo n.º 11
0
    def setUp(self):
        super(ActiveUsersListTests, self).setUp()
        self.link = '/api/users/?list=active'

        cache.clear()
        threadstore.clear()

        self.forum = Forum.objects.all_forums().filter(role="forum")[:1][0]
        self.forum.labels = []
Ejemplo n.º 12
0
    def setUp(self):
        super(WarningTestCase, self).setUp()
        self.test_user = get_user_model().objects.create_user(
            "Bob", "*****@*****.**", "Pass.123")
        self.link_kwargs = {'user_slug': 'bob', 'user_id': self.test_user.pk}

        self.warning_levels = (
            WarningLevel.objects.create(name='Lvl 1'),
            WarningLevel.objects.create(name='Lvl 2'),
            WarningLevel.objects.create(name='Lvl 3'),
            WarningLevel.objects.create(name='Lvl 4'),
        )

        cache.clear()
        threadstore.clear()
Ejemplo n.º 13
0
    def setUp(self):
        super(WarningTestCase, self).setUp()
        self.test_user = get_user_model().objects.create_user(
            "Bob", "*****@*****.**", "Pass.123")
        self.link_kwargs = {'user_slug': 'bob', 'user_id': self.test_user.pk}

        self.warning_levels = (
            WarningLevel.objects.create(name='Lvl 1'),
            WarningLevel.objects.create(name='Lvl 2'),
            WarningLevel.objects.create(name='Lvl 3'),
            WarningLevel.objects.create(name='Lvl 4'),
        )

        cache.clear()
        threadstore.clear()
Ejemplo n.º 14
0
    def test_warnings(self):
        """user warning levels is obtained"""
        threadstore.clear()
        cache.clear()

        self.assertTrue(warnings.is_user_warning_level_max(self.test_user))

        levels = (
            WarningLevel.objects.create(name="Level 1"),
            WarningLevel.objects.create(name="Level 2"),
            WarningLevel.objects.create(name="Level 3"),
            WarningLevel.objects.create(name="Level 4"),
            WarningLevel.objects.create(name="Level 5"),
            WarningLevel.objects.create(name="Level 6"),
            WarningLevel.objects.create(name="Level 7"),
            WarningLevel.objects.create(name="Level 8")
        )

        self.assertEqual(WarningLevel.objects.count(), 8)

        threadstore.clear()
        cache.clear()

        for level, warning in enumerate(levels):
            warnings.warn_user(self.test_mod, self.test_user, "bawww")

            user_level = warnings.get_user_warning_level(self.test_user)
            user_level_obj = warnings.get_user_warning_obj(self.test_user)

            self.assertEqual(user_level, level + 1)
            self.assertEqual(user_level_obj.name, levels[level].name)
            self.assertEqual(self.test_user.warning_level, level + 1)

        self.assertTrue(warnings.is_user_warning_level_max(self.test_user))

        previous_level = user_level
        for warning in self.test_user.warnings.all():
            warnings.cancel_warning(self.test_mod, self.test_user, warning)
            user_level = warnings.get_user_warning_level(self.test_user)
            self.assertEqual(user_level + 1, previous_level)
            previous_level = user_level

        self.assertEqual(0, warnings.get_user_warning_level(self.test_user))
Ejemplo n.º 15
0
    def test_warnings(self):
        """user warning levels is obtained"""
        threadstore.clear()
        cache.clear()

        self.assertTrue(warnings.is_user_warning_level_max(self.test_user))

        levels = (WarningLevel.objects.create(name="Level 1"),
                  WarningLevel.objects.create(name="Level 2"),
                  WarningLevel.objects.create(name="Level 3"),
                  WarningLevel.objects.create(name="Level 4"),
                  WarningLevel.objects.create(name="Level 5"),
                  WarningLevel.objects.create(name="Level 6"),
                  WarningLevel.objects.create(name="Level 7"),
                  WarningLevel.objects.create(name="Level 8"))

        self.assertEqual(WarningLevel.objects.count(), 8)

        threadstore.clear()
        cache.clear()

        for level, warning in enumerate(levels):
            warnings.warn_user(self.test_mod, self.test_user, "bawww")

            user_level = warnings.get_user_warning_level(self.test_user)
            user_level_obj = warnings.get_user_warning_obj(self.test_user)

            self.assertEqual(user_level, level + 1)
            self.assertEqual(user_level_obj.name, levels[level].name)
            self.assertEqual(self.test_user.warning_level, level + 1)

        self.assertTrue(warnings.is_user_warning_level_max(self.test_user))

        previous_level = user_level
        for warning in self.test_user.warnings.all():
            warnings.cancel_warning(self.test_mod, self.test_user, warning)
            user_level = warnings.get_user_warning_level(self.test_user)
            self.assertEqual(user_level + 1, previous_level)
            previous_level = user_level

        self.assertEqual(0, warnings.get_user_warning_level(self.test_user))
Ejemplo n.º 16
0
 def setUp(self):
     threadstore.clear()
Ejemplo n.º 17
0
    def setUp(self):
        super(OnlineListTests, self).setUp()
        self.link = '/api/users/?list=online'

        cache.clear()
        threadstore.clear()
Ejemplo n.º 18
0
 def tearDown(self):
     threadstore.clear()
Ejemplo n.º 19
0
 def process_response(self, request, response):
     threadstore.clear()
     return response
Ejemplo n.º 20
0
    def setUp(self):
        cache.clear()
        threadstore.clear()

        self.cache_name = 'eric_the_fish'
        cachebuster.register(self.cache_name)
Ejemplo n.º 21
0
    def setUp(self):
        """
        Create categories tree for test cases:

        First category (created by migration)

        Category A
          + Category B
            + Subcategory C
            + Subcategory D

        Category E
          + Subcategory F
        """

        super(CategoriesUtilsTests, self).setUp()
        threadstore.clear()

        self.root = Category.objects.root_category()
        self.first_category = Category.objects.get(slug='first-category')

        Category(
            name='Category A',
            slug='category-a',
        ).insert_at(
            self.root,
            position='last-child',
            save=True,
        )
        Category(
            name='Category E',
            slug='category-e',
        ).insert_at(
            self.root,
            position='last-child',
            save=True,
        )

        self.category_a = Category.objects.get(slug='category-a')

        Category(
            name='Category B',
            slug='category-b',
        ).insert_at(
            self.category_a,
            position='last-child',
            save=True,
        )

        self.category_b = Category.objects.get(slug='category-b')

        Category(
            name='Subcategory C',
            slug='subcategory-c',
        ).insert_at(
            self.category_b,
            position='last-child',
            save=True,
        )
        Category(
            name='Subcategory D',
            slug='subcategory-d',
        ).insert_at(
            self.category_b,
            position='last-child',
            save=True,
        )

        self.category_e = Category.objects.get(slug='category-e')
        Category(
            name='Subcategory F',
            slug='subcategory-f',
        ).insert_at(
            self.category_e,
            position='last-child',
            save=True,
        )

        categories_acl = {'categories': {}, 'visible_categories': []}
        for category in Category.objects.all_categories():
            categories_acl['visible_categories'].append(category.pk)
            categories_acl['categories'][category.pk] = {'can_see': 1, 'can_browse': 1}
        override_acl(self.user, categories_acl)
    def tearDown(self):
        super().tearDown()

        cache.clear()
        threadstore.clear()
Ejemplo n.º 23
0
 def tearDown(self):
     cache.clear()
     threadstore.clear()
Ejemplo n.º 24
0
    def setUp(self):
        super(ChangeEmailPasswordTests, self).setUp()
        self.view_link = reverse('misago:usercp_change_email_password')

        threadstore.clear()
Ejemplo n.º 25
0
    def tearDown(self):
        super(TestActivePostersRanking, self).tearDown()

        cache.clear()
        threadstore.clear()
Ejemplo n.º 26
0
 def tearDown(self):
     threadstore.clear()
Ejemplo n.º 27
0
 def clear_state(self):
     cache.clear()
     threadstore.clear()
Ejemplo n.º 28
0
 def tearDown(self):
     cache.clear()
     threadstore.clear()
Ejemplo n.º 29
0
    def tearDown(self):
        super(TestActivePostersRanking, self).tearDown()

        cache.clear()
        threadstore.clear()
Ejemplo n.º 30
0
    def setUp(self):
        super(OnlineListTests, self).setUp()
        self.link = '/api/users/?list=online'

        cache.clear()
        threadstore.clear()
Ejemplo n.º 31
0
    def setUp(self):
        super(ChangeEmailPasswordTests, self).setUp()
        self.view_link = reverse('misago:usercp_change_email_password')

        threadstore.clear()