From c0f512aca64d0e6f7f0cf9792e5e9929ea5dd260 Mon Sep 17 00:00:00 2001 From: zming <517046497@qq.com> Date: Sat, 15 Jul 2017 12:24:52 +0800 Subject: [PATCH] update test --- seahub/api2/endpoints/admin/two_factor_auth.py | 3 ++- tests/api/endpoints/admin/test_two_factor_auth.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/seahub/api2/endpoints/admin/two_factor_auth.py b/seahub/api2/endpoints/admin/two_factor_auth.py index a04882a0f0..0bc2ad7e97 100644 --- a/seahub/api2/endpoints/admin/two_factor_auth.py +++ b/seahub/api2/endpoints/admin/two_factor_auth.py @@ -10,7 +10,6 @@ from seahub.api2.throttling import UserRateThrottle from seahub.api2.utils import json_response, api_error from seahub.api2.authentication import TokenAuthentication from seahub.utils.two_factor_auth import has_two_factor_auth, two_factor_auth_enabled -from seahub_extra.two_factor import devices_for_user class TwoFactorAuthView(APIView): @@ -27,6 +26,8 @@ class TwoFactorAuthView(APIView): except User.DoesNotExist: error_msg = "User %s not found" % email return api_error(status.HTTP_400_BAD_REQUEST, error_msg) + + from seahub_extra.two_factor import devices_for_user devices = devices_for_user(_user) if devices: for device in devices: diff --git a/tests/api/endpoints/admin/test_two_factor_auth.py b/tests/api/endpoints/admin/test_two_factor_auth.py index 3a28eb8e90..ce234195f7 100644 --- a/tests/api/endpoints/admin/test_two_factor_auth.py +++ b/tests/api/endpoints/admin/test_two_factor_auth.py @@ -1,20 +1,24 @@ - +import os +import pytest from django.core.urlresolvers import reverse from seahub.test_utils import BaseTestCase -from seahub_extra.two_factor import devices_for_user -from seahub_extra.two_factor.models import (StaticDevice, TOTPDevice, - PhoneDevice) + +TRAVIS = 'TRAVIS' in os.environ +@pytest.mark.skipif(TRAVIS, reason="") class TwoFactorAuthViewTest(BaseTestCase): def setUp(self): self.login_as(self.admin) def test_can_disable_two_factor_auth(self): + from seahub_extra.two_factor.models import (StaticDevice, TOTPDevice, + PhoneDevice) totp = TOTPDevice(user=self.admin, name="", confirmed=1) totp.save() + from seahub_extra.two_factor import devices_for_user devices = devices_for_user(self.admin) i = 0 for device in devices_for_user(self.admin):