コード例 #1
0
ファイル: test_checks.py プロジェクト: ishitatsuyuki/relate
    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()
コード例 #2
0
ファイル: test_checks.py プロジェクト: lacrosse91/relate
    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()
コード例 #3
0
ファイル: test_checks.py プロジェクト: ishitatsuyuki/relate
    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))
コード例 #4
0
ファイル: test_checks.py プロジェクト: lacrosse91/relate
    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))
コード例 #5
0
ファイル: test_checks.py プロジェクト: lacrosse91/relate
 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))
コード例 #6
0
ファイル: test_checks.py プロジェクト: ishitatsuyuki/relate
 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))