Esempio n. 1
0
    def test_passed_check_but_return_empty_string(self):
        with override_settings(
                RELATE_USER_PROFILE_MASK_METHOD=(
                        "tests.resource"
                        ".my_custom_get_masked_profile_method_valid_but_return_emtpy_string")):  # noqa
            self.assertCheckMessages([])
            from tests.resource import (
                my_custom_get_masked_profile_method_valid_but_return_emtpy_string
                as custom_method)

            # test method can run
            custom_method(self.user)

            with self.assertRaises(RuntimeError):
                self.user.get_masked_profile()
Esempio n. 2
0
    def test_passed_check_but_return_none(self):
        with override_settings(RELATE_USER_PROFILE_MASK_METHOD=(
                "tests.resource"
                ".my_custom_get_masked_profile_method_valid_but_return_none"
        )):  # noqa
            self.assertCheckMessages([])
            from tests.resource import (
                my_custom_get_masked_profile_method_valid_but_return_none as
                custom_method)

            # test method can run
            custom_method(self.user)

            with self.assertRaises(RuntimeError):
                self.user.get_masked_profile()
Esempio n. 3
0
    def test_get_masked_profile_valid_method1(self):
        def custom_method(u):
            return "%s%s" % ("User", str(u.pk + 1))

        with override_settings(RELATE_USER_PROFILE_MASK_METHOD=custom_method):
            self.assertCheckMessages([])
            self.assertEqual(self.user.get_masked_profile(),
                             custom_method(self.user))
Esempio n. 4
0
    def test_get_masked_profile_valid_method1(self):
        def custom_method(u):
            return "%s%s" % ("User", str(u.pk + 1))

        with override_settings(RELATE_USER_PROFILE_MASK_METHOD=custom_method):
            self.assertCheckMessages([])
            self.assertEqual(self.user.get_masked_profile(),
                             custom_method(self.user))
Esempio n. 5
0
 def test_get_masked_profile_valid_method_path(self):
     with override_settings(RELATE_USER_PROFILE_MASK_METHOD=(
             "tests.resource"
             ".my_custom_get_masked_profile_method_valid")):
         self.assertCheckMessages([])
         from tests.resource import (
             my_custom_get_masked_profile_method_valid as custom_method)
         self.assertEqual(self.user.get_masked_profile(),
                          custom_method(self.user))
Esempio n. 6
0
 def test_get_masked_profile_valid_method_path(self):
     with override_settings(
             RELATE_USER_PROFILE_MASK_METHOD=(
                     "tests.resource"
                     ".my_custom_get_masked_profile_method_valid")):
         self.assertCheckMessages([])
         from tests.resource import (
             my_custom_get_masked_profile_method_valid as custom_method)
         self.assertEqual(self.user.get_masked_profile(),
                          custom_method(self.user))