Ejemplo n.º 1
0
class EmailAuthTest(TestCase):
    """
    Testing EmailAuth.auth_complete method.
    """
    def setUp(self):
        self.test_email = '*****@*****.**'
        self.email_auth = EmailAuth()
        self.email_auth.strategy = mock.Mock()
        self.email_auth.strategy.request.GET.get.return_value = True

        code_object = mock.Mock()
        code_object.email = self.test_email
        self.first = mock.Mock()
        self.first.first.return_value = code_object

    def test_update_email_from_code_custom_code_found(self, code):
        code.objects.filter.return_value = self.first
        self.email_auth.auth_complete()
        self.assertEqual(self.email_auth.data.get('email'), self.test_email)

    def test_update_email_from_code_no_custom_code_found(self, code):
        self.first = mock.Mock()
        self.first.first.return_value = None
        code.objects.filter.return_value = self.first
        with self.assertRaises(AuthMissingParameter):
            self.email_auth.auth_complete()
Ejemplo n.º 2
0
class EmailAuthTest(TestCase):
    """
    Testing EmailAuth.auth_complete method.
    """
    def setUp(self):
        self.test_email = '*****@*****.**'
        self.email_auth = EmailAuth()
        self.email_auth.strategy = mock.Mock()
        self.email_auth.strategy.request.GET.get.return_value = True

        code_object = mock.Mock()
        code_object.email = self.test_email
        self.first = mock.Mock()
        self.first.first.return_value = code_object

    def test_update_email_from_code_custom_code_found(self, code):
        code.objects.filter.return_value = self.first
        self.email_auth.auth_complete()
        self.assertEqual(self.email_auth.data.get('email'), self.test_email)

    def test_update_email_from_code_no_custom_code_found(self, code):
        self.first = mock.Mock()
        self.first.first.return_value = None
        code.objects.filter.return_value = self.first
        with self.assertRaises(AuthMissingParameter):
            self.email_auth.auth_complete()
Ejemplo n.º 3
0
    def setUp(self):
        self.test_email = '*****@*****.**'
        self.email_auth = EmailAuth()
        self.email_auth.strategy = mock.Mock()
        self.email_auth.strategy.request.REQUEST.get.return_value = True

        code_object = mock.Mock()
        code_object.email = self.test_email
        self.first = mock.Mock()
        self.first.first.return_value = code_object
Ejemplo n.º 4
0
class EmailAuthTest(TestCase):
    """
    Testing EmailAuth.auth_complete method.
    """
    def setUp(self):
        self.test_email = '*****@*****.**'
        self.email_auth = EmailAuth()
        self.email_auth.strategy = mock.Mock()
        self.email_auth.strategy.request.REQUEST.get.return_value = True

        code_object = mock.Mock()
        code_object.email = self.test_email
        self.first = mock.Mock()
        self.first.first.return_value = code_object

    def test_update_email_from_code(self, code):
        code.objects.filter.return_value = self.first
        self.email_auth.auth_complete()
        self.assertEqual(self.email_auth.data.get('email'), self.test_email)
Ejemplo n.º 5
0
    def setUp(self):
        self.test_email = '*****@*****.**'
        self.email_auth = EmailAuth()
        self.email_auth.strategy = mock.Mock()
        self.email_auth.strategy.request.GET.get.return_value = True

        code_object = mock.Mock()
        code_object.email = self.test_email
        self.first = mock.Mock()
        self.first.first.return_value = code_object
Ejemplo n.º 6
0
class EmailAuthTest(TestCase):
    """
    Testing EmailAuth.auth_complete method.
    """
    def setUp(self):
        self.test_email = '*****@*****.**'
        self.email_auth = EmailAuth()
        self.email_auth.strategy = mock.Mock()
        self.email_auth.strategy.request.REQUEST.get.return_value = True

        code_object = mock.Mock()
        code_object.email = self.test_email
        self.first = mock.Mock()
        self.first.first.return_value = code_object

    def test_update_email_from_code(self, code):
        code.objects.filter.return_value = self.first
        self.email_auth.auth_complete()
        self.assertEqual(self.email_auth.data.get('email'), self.test_email)