• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python helpers.SocialClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中wildlifelicensing.apps.main.tests.helpers.SocialClient的典型用法代码示例。如果您正苦于以下问题:Python SocialClient类的具体用法?Python SocialClient怎么用?Python SocialClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SocialClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: lodge_application

def lodge_application(application):
    """
    :param application:
    """
    client = SocialClient()
    client.login(application.applicant.email)
    client.get(reverse('wl_applications:edit_application', args=[application.pk]))
    url = reverse_lazy('wl_applications:preview')
    client.post(url)
    application.refresh_from_db()
    client.logout()
    return application
开发者ID:wilsonc86,项目名称:ledger,代码行数:12,代码来源:helpers.py


示例2: setUp

    def setUp(self):
        create_default_country()
        self.customer = get_or_create_default_customer()

        self.officer = get_or_create_default_officer()

        self.client = SocialClient()
开发者ID:wilsonc86,项目名称:ledger,代码行数:7,代码来源:tests.py


示例3: setUp

    def setUp(self):
        self.customer = create_default_customer()

        self.client = SocialClient()

        licence_type = WildlifeLicenceType.objects.get(code='regulation17')
        licence_type.identification_required = True
        licence_type.save()
开发者ID:ropable,项目名称:ledger,代码行数:8,代码来源:test_entry.py


示例4: setUp

    def setUp(self):
        self.customer = get_or_create_default_customer(include_default_profile=True)
        self.officer = get_or_create_default_officer()

        self.client = SocialClient()

        self.licence = create_licence(self.customer, self.officer, product_title='regulation-17')
        self.ret = create_return(self.licence)
开发者ID:wilsonc86,项目名称:ledger,代码行数:8,代码来源:test_returns.py


示例5: setUp

    def setUp(self):
        helpers.create_default_country()
        self.customer = get_or_create_default_customer()

        self.client = SocialClient()

        self.licence_type = WildlifeLicenceType.objects.get(product_title='regulation-17')
        self.licence_type.identification_required = True
        self.licence_type.save()
开发者ID:gaiaresources,项目名称:ledger,代码行数:9,代码来源:test_entry.py


示例6: get_action_log

def get_action_log(application):
    client = SocialClient()
    officer = get_or_create_default_officer()
    client.login(officer.email)
    url = reverse('wl_applications:action_list', args=[application.pk])
    resp = client.get(url)
    client.logout()
    return resp.json()['data']
开发者ID:wilsonc86,项目名称:ledger,代码行数:8,代码来源:helpers.py


示例7: lodge_application

def lodge_application(application):
    """
    :param application:
    """
    client = SocialClient()
    client.login(application.applicant_profile.user.email)
    url = reverse_lazy("wl_applications:preview", args=[application.licence_type.code_slug, application.pk])
    session = client.session
    session["application"] = {"profile": application.applicant_profile.pk, "data": application.data}
    session.save()
    client.post(url)
    application.refresh_from_db()
    client.logout()
    return application
开发者ID:serge-gaia,项目名称:ledger,代码行数:14,代码来源:helpers.py


示例8: setUp

    def setUp(self):
        self.client = SocialClient()
        self.user = get_or_create_default_customer()
        self.officer = get_or_create_default_officer()
        self.application = app_helpers.create_and_lodge_application(self.user, **{
            'data': {
                'title': 'My Application'
            }
        })

        self.assessor_group = G(AssessorGroup, name='District7', email='[email protected]')
        self.assessor_1 = G(EmailUser, email='[email protected]', dob='1967-04-04')
        add_to_group(self.assessor_1, 'Assessors')
        add_to_group(self.assessor_1, self.assessor_group)

        self.assessor_2 = G(EmailUser, email='[email protected]', dob='1968-04-04')
        add_to_group(self.assessor_2, 'Assessors')
        add_to_group(self.assessor_2, self.assessor_group)
开发者ID:wilsonc86,项目名称:ledger,代码行数:18,代码来源:test_conditions.py


示例9: issue_licence

def issue_licence(application=None, user=None, licence_data=None):
    if application is None:
        application = create_and_lodge_application(user)
    if user is None:
        user = get_or_create_default_officer()
    client = SocialClient()
    client.login(user.email)
    if licence_data is None:
        licence_data = {}
    data = get_minimum_data_for_issuing_licence()
    data.update(licence_data)
    url = reverse('wl_applications:issue_licence', args=[application.pk])
    client.post(url, data=data, follow=True)
    client.logout()
    application.refresh_from_db()
    assert application.licence
    return application.licence
开发者ID:wilsonc86,项目名称:ledger,代码行数:17,代码来源:helpers.py


示例10: lodge_application

def lodge_application(application):
    """
    :param application:
    """
    client = SocialClient()
    client.login(application.applicant_profile.user.email)
    url = reverse_lazy('applications:preview', args=[application.licence_type.code, application.pk])
    session = client.session
    session['application'] = {
        'profile': application.applicant_profile.pk,
        'data': application.data
    }
    session.save()
    client.post(url)
    application.refresh_from_db()
    client.logout()
    return application
开发者ID:rockychen-dpaw,项目名称:ledger,代码行数:17,代码来源:helpers.py


示例11: AccountsTestCase

class AccountsTestCase(TestCase):
    def setUp(self):
        self.customer = get_or_create_default_customer()

        self.officer = get_or_create_default_officer()

        self.client = SocialClient()

    def tearDown(self):
        self.client.logout()
        # clean id file
        if self.customer.identification:
            os.remove(self.customer.identification.path)

    def test_profile_list(self):
        """Testing that a user can display the profile list if they are a customer"""
        self.client.login(self.customer.email)

        # check that client can access the profile list
        response = self.client.get(reverse('wl_main:list_profiles'))
        self.assertEqual(200, response.status_code)

    def test_profile_list_non_customer(self):
        """Testing that a user cannot display the profile list if they are not a customer"""
        self.client.login(self.officer.email)

        # check that client gets redirected if they try to access the profile list
        response = self.client.get(reverse('wl_main:list_profiles'))
        self.assertEqual(302, response.status_code)

    def test_create_profile(self):
        """Testing that a user can create a profile"""
        self.client.login(self.customer.email)

        original_profile_count = Profile.objects.filter(user=self.customer).count()

        # check that client can access the create profile page
        response = self.client.get(reverse('wl_main:create_profile'))
        self.assertEqual(200, response.status_code)

        post_params = {
            'user': self.customer.pk,
            'name': 'Test Profile',
            'email': '[email protected]',
            'institution': 'Test Institution',
            'line1': '1 Test Street',
            'locality': 'Test Suburb',
            'state': 'WA',
            'country': 'AU',
            'postcode': '0001'
        }

        response = self.client.post(reverse('wl_main:create_profile'), post_params)
        self.assertEqual(302, response.status_code)

        # check that a new profile has been created
        self.assertEquals(Profile.objects.filter(user=self.customer).count(), original_profile_count + 1)

    def test_edit_profile(self):
        """Testing that a user can edit an existing profile"""
        self.client.login(self.customer.email)

        # create original profile
        address = Address.objects.create(line1='1 Test Street', locality='Test Suburb', state='WA', postcode='0001')
        profile = Profile.objects.create(user=self.customer, name='Test Profile', email='[email protected]',
                                         institution='Test Institution', postal_address=address)

        # check that client can access the edit profile page
        response = self.client.get(reverse('wl_main:edit_profile', args=(profile.pk,)))
        self.assertEqual(200, response.status_code)

        post_params = {
            'user': self.customer.pk,
            'name': 'Test Profile 2',
            'email': profile.email,
            'institution': profile.institution,
            'line1': '2 Test Street',
            'locality': address.locality,
            'state': address.state,
            'country': 'AU',
            'postcode': address.postcode
        }

        response = self.client.post(reverse('wl_main:edit_profile', args=(profile.pk,)), post_params)
        self.assertEqual(302, response.status_code)

        # get updated profile
        profile = Profile.objects.get(pk=profile.pk)

        # check that the profile has been edited
        self.assertEquals(profile.name, 'Test Profile 2')
        self.assertEquals(profile.postal_address.line1, '2 Test Street')

    def test_manage_id(self):
        """Testing that a user can access the manage identification page"""
        self.client.login(self.customer.email)

        # check that client can access the manage identification page
        response = self.client.get(reverse('wl_main:identification'))
        self.assertEqual(200, response.status_code)
#.........这里部分代码省略.........
开发者ID:serge-gaia,项目名称:ledger,代码行数:101,代码来源:tests.py


示例12: TestPermissions

class TestPermissions(TestCase):
    fixtures = ['licences.json', 'countries.json', 'catalogue.json', 'partner.json', 'returns.json']

    def setUp(self):
        self.customer = get_or_create_default_customer(include_default_profile=True)
        self.officer = get_or_create_default_officer()
        self.assessor = get_or_create_default_assessor()
        self.not_allowed_customer = create_random_customer()
        self.assertNotEqual(self.not_allowed_customer, self.customer)

        self.client = SocialClient()
        self.licence = create_licence(self.customer, self.officer, product_title='regulation-17')
        self.ret = create_return(self.licence)

    def test_returns_lodgement_page(self):
        """
        Only officer or application owner can view returns
        """
        url = reverse('wl_returns:enter_return', args=(self.ret.pk,))
        allowed = [self.officer, self.customer]
        forbidden = [self.not_allowed_customer, self.assessor]

        for user in allowed:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(200, response.status_code)
            self.client.logout()

        for user in forbidden:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(403, response.status_code)
            self.client.logout()

    def test_readonly_view(self):
        """
        Only officer or application owner can enter returns
        """
        url = reverse('wl_returns:view_return', args=(self.ret.pk,))
        allowed = [self.officer, self.customer]
        forbidden = [self.not_allowed_customer, self.assessor]

        for user in allowed:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(200, response.status_code)
            self.client.logout()

        for user in forbidden:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(403, response.status_code)
            self.client.logout()

    def test_curate_view(self):
        """
        Only officer can curate returns
        """
        url = reverse('wl_returns:curate_return', args=(self.ret.pk,))
        allowed = [self.officer]
        forbidden = [self.not_allowed_customer, self.assessor, self.customer]

        for user in allowed:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(200, response.status_code)
            self.client.logout()

        for user in forbidden:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(403, response.status_code)
            self.client.logout()

    def test_view_log(self):
        """
        Only officer can view log
        """
        url = reverse('wl_returns:log_list', args=(self.ret.pk,))
        allowed = [self.officer]
        forbidden = [self.not_allowed_customer, self.assessor, self.customer]

        for user in allowed:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(200, response.status_code)
            self.client.logout()

        for user in forbidden:
            self.client.login(user.email)
            response = self.client.get(url)
            self.assertEqual(403, response.status_code)
            self.client.logout()

    def test_add_log(self):
        """
        Only officer can view log
        """
        url = reverse('wl_returns:add_log_entry', args=(self.ret.pk,))
        allowed = [self.officer]
#.........这里部分代码省略.........
开发者ID:wilsonc86,项目名称:ledger,代码行数:101,代码来源:test_returns.py


示例13: TestLifeCycle

class TestLifeCycle(TestCase):
    fixtures = ['licences.json', 'countries.json', 'catalogue.json', 'partner.json', 'returns.json']

    def setUp(self):
        self.customer = get_or_create_default_customer(include_default_profile=True)
        self.officer = get_or_create_default_officer()
        self.assessor = get_or_create_default_assessor()
        self.not_allowed_customer = create_random_customer()
        self.assertNotEqual(self.not_allowed_customer, self.customer)

        self.client = SocialClient()
        self.licence_type = get_or_create_licence_type('regulation-17')
        self.return_type = get_or_create_return_type(self.licence_type)

    def tearDown(self):
        self.client.logout()

    def _issue_licence(self, licence_data, **kwargs):
        application = app_helpers.create_and_lodge_application(self.customer, **{
            'applicant': kwargs.get('applicant', self.customer),
            'licence_type': kwargs.get('licence_type', self.licence_type)
        })
        self.assertIsNotNone(application)
        self.assertEqual(application.applicant, self.customer)
        self.assertIsNone(application.proxy_applicant)
        licence = app_helpers.issue_licence(
            application,
            kwargs.get('issuer', self.officer),
            licence_data=licence_data
        )
        self.assertEqual(licence.holder, self.customer)
        self.assertIsNotNone(licence)
        return licence

    def _lodge_reg17_return(self, ret, data=None):
        post_params = {
            'lodge': True,
        }
        data = data or TEST_VALUES
        for key, value in data.items():
            post_params['regulation-17::{}'.format(key)] = value

        holder = ret.licence.holder
        self.client.login(holder.email)
        response = self.client.post(reverse('wl_returns:enter_return', args=(ret.pk,)), post_params)
        self.assertRedirects(response, reverse('home'),
                             status_code=302, target_status_code=200, fetch_redirect_response=False)
        ret.refresh_from_db()
        self.client.logout()
        return data

    def _create_and_lodge_return(self):
        start_date = date.today()
        end_date = start_date + relativedelta(months=2)  # 2 months licence
        licence_data = {
            'return_frequency': -1,  # one off
            'start_date': str(start_date),
            'end_date': str(end_date)
        }
        licence = self._issue_licence(licence_data)
        self.assertIsNotNone(licence)

        ret = Return.objects.first()
        expected_status = 'current'
        self.assertEqual(ret.status, expected_status)
        data = self._lodge_reg17_return(ret)
        expected_status = 'submitted'
        self.assertEqual(ret.status, expected_status)
        return ret, data

    def _create_lodge_and_amend_return(self):
        ret, data = self._create_and_lodge_return()
        expected_status = 'submitted'
        self.assertEqual(ret.status, expected_status)

        url = reverse('wl_returns:amendment_request')
        curator = self.officer
        self.client.login(curator.email)
        payload = {
            'ret': ret.pk,
            'officer': curator.pk,
            'reason': 'Chubby bat is not a valid species'
        }
        resp = self.client.post(url, data=payload)
        self.assertEqual(resp.status_code, 200)
        ret.refresh_from_db()
        expected_status = 'amendment_required'
        self.assertEqual(ret.status, expected_status)
        self.assertEqual(ret.pending_amendments_qs.count(), 1)
        self.client.logout()
        return ret

    def test_initial_states_with_future(self):
        """
        Test that after the licence has been created some returns has been created according to the return frequency
        and the licence end date
        """
        # issue licence
        # use a one year licence with a monthly return
        start_date = today = date.today()
#.........这里部分代码省略.........
开发者ID:wilsonc86,项目名称:ledger,代码行数:101,代码来源:test_returns.py


示例14: ApplicationEntrySecurity

class ApplicationEntrySecurity(TransactionTestCase):
    fixtures = ['licences.json']
    serialized_rollback = True

    def setUp(self):
        self.client = SocialClient()

    def tearDown(self):
        self.client.logout()

    def test_user_access_other_user(self):
        """
        Test that a user cannot edit/view another user application
        """
        customer1 = create_random_customer()
        customer2 = create_random_customer()
        self.assertNotEqual(customer1, customer2)

        application1 = helpers.create_application(user=customer1)
        application2 = helpers.create_application(user=customer2)
        self.assertNotEqual(application1, application2)

        # login as user1
        self.client.login(customer1.email)
        my_url = reverse('wl_applications:edit_application', args=[application1.pk])
        response = self.client.get(my_url)
        self.assertEqual(302, response.status_code)

        forbidden_urls = [
            reverse('wl_applications:edit_application', args=[application2.pk]),
        ]

        for forbidden_url in forbidden_urls:
            response = self.client.get(forbidden_url, follow=True)
            self.assertEqual(403, response.status_code)

    def test_user_access_lodged(self):
        """
        Once the application if lodged the user should not be able to edit it
        """
        customer1 = create_random_customer()
        self.client.login(customer1)

        self.client.get(reverse('wl_applications:new_application'))
        self.client.get(reverse('wl_applications:select_licence_type', args=(1,)))

        application = Application.objects.first()
        self.assertIsNotNone(application)
        self.assertIsNotNone(application.applicant)

        # check that the state of the application is temp
        self.assertEqual(application.processing_status, 'temp')

        response = self.client.post(reverse('wl_applications:preview'))

        # check that client is redirected to checkout
        self.assertRedirects(response, reverse('wl_payments:checkout_application', args=(application.pk,)),
                             status_code=302, target_status_code=200, fetch_redirect_response=False)

        application.refresh_from_db()

        # check that the state of the application is new/underreview
        self.assertEqual(application.processing_status, 'new')
        self.assertEqual('under_review', application.customer_status)

        response = self.client.get(reverse('wl_applications:edit_application', args=[application.pk]), follow=True)
        self.assertEqual(403, response.status_code)

    def test_user_not_logged_is_redirected_to_login(self):
        """
        A user not logged in should be redirected to the login page and not see a 403
        """
        customer1 = create_random_customer()
        self.client.login(customer1)

        self.client.get(reverse('wl_applications:new_application'))
        self.client.get(reverse('wl_applications:select_licence_type', args=(1,)))

        application = Application.objects.first()
        self.assertIsNotNone(application)

        # check that the state of the application is temp
        self.assertEqual(application.processing_status, 'temp')

        response = self.client.post(reverse('wl_applications:preview'))

        # check that client is redirected to checkout
        self.assertRedirects(response, reverse('wl_payments:checkout_application', args=(application.pk,)),
                             status_code=302, target_status_code=200, fetch_redirect_response=False)

        application.refresh_from_db()

        # check that the state of the application is new/underreview
        self.assertEqual(application.processing_status, 'new')
        self.assertEqual('under_review', application.customer_status)

        # logout
        self.client.logout()

        response = self.client.get(reverse('wl_applications:edit_application', args=[application.pk]), follow=True)
#.........这里部分代码省略.........
开发者ID:gaiaresources,项目名称:ledger,代码行数:101,代码来源:test_entry.py


示例15: setUp

    def setUp(self):
        self.client = SocialClient()
        self.user = get_or_create_default_customer()
        self.officer = get_or_create_default_officer()
        self.application = create_and_lodge_application(self.user, **{
            'data': {
                'title': 'My Application'
            }
        })
        self.process_urls_get = [
            reverse('wl_applications:process', args=[self.application.pk]),
        ]

        self.process_urls_post = [
            {
                'url': reverse('wl_applications:process', args=[self.application.pk]),
                'data': {
                    'applicationID': self.application.pk,
                }
            },
            {
                'url': reverse('wl_applications:assign_officer'),
                'data': {
                    'applicationID': self.application.pk,
                    'userID': self.officer.pk,
                }
            },
            {
                'url': reverse('wl_applications:set_id_check_status'),
                'data': {
                    'applicationID': self.application.pk,
                    'status': 'accepted',
                }
            },
            {
                'url': reverse('wl_applications:id_request'),
                'data': {
                    'applicationID': self.application.pk,
                }
            },
            {
                'url': reverse('wl_applications:set_character_check_status'),
                'data': {
                    'applicationID': self.application.pk,
                    'status': 'accepted',
                }
            },
            {
                'url': reverse('wl_applications:set_review_status'),
                'data': {
                    'applicationID': self.application.pk,
                    'status': 'accepted',
                }
            },
            {
                'url': reverse('wl_applications:amendment_request'),
                'data': {
                    'applicationID': self.application.pk,
                }
            },
            {
                'url': reverse('wl_applications:send_for_assessment'),
                'data': {
                    'applicationID': self.application.pk,
                    'assGroupID': get_or_create_default_assessor_group().pk,
                    'status': 'awaiting_assessment'
                }
            },
            {
                'url': reverse('wl_applications:remind_assessment'),
                'data': {
                    'applicationID': self.application.pk,
                    'assessmentID': get_or_create_assessment(self.application).pk
                }
            },
        ]
开发者ID:wilsonc86,项目名称:ledger,代码行数:76,代码来源:test_process.py


示例16: TestStatusLifeCycle

class TestStatusLifeCycle(TestCase):
    fixtures = ['licences.json']

    def setUp(self):
        self.client = SocialClient()
        self.officer = get_or_create_default_officer()
        self.user = get_or_create_default_customer()
        self.assertNotEqual(self.officer, self.user)

    def tearDown(self):
        self.client.logout()
        clear_mailbox()
        clear_all_id_files()

    def test_id_update(self):
        """
        Test that when an ID update is required and the users update their ID the customer and id status are correctly
         updated
        """
        application = create_and_lodge_application(self.user)
        self.client.login(self.officer.email)
        self.assertTrue(is_client_authenticated(self.client))
        clear_mailbox()
        data = {
            'officer': self.officer.pk,
            'application': application.pk,
            'reason': IDRequest.REASON_CHOICES[0][0],
            'text': 'you to upload an ID.'
        }
        url = reverse('wl_applications:id_request')
        self.assertFalse(is_email())
        response = self.client.post(url, data)
        self.assertEqual(200, response.status_code)
        resp_data = json.loads(response.content.decode('utf8'))
        self.assertIn('id_check_status', resp_data)
        self.assertIn('processing_status', resp_data)
        application.refresh_from_db()
        self.assertEqual('id_required', application.customer_status)
        self.assertEqual('awaiting_update', application.id_check_status)
        self.assertEqual('awaiting_applicant_response', application.processing_status)
        self.assertTrue(is_email())
        email = get_email()
        self.assertIn(application.applicant_profile.email, email.to)
        self.assertEqual(ApplicationIDUpdateRequestedEmail.subject, email.subject)

        # now user upload ID
        self.client.logout()
        self.assertIsNone(self.user.identification)
        self.client.login(self.user.email)
        self.assertTrue(is_client_authenticated(self.client))
        self.client.get(reverse('wl_main:identification'))
        upload_id(self.user)
        self.user.refresh_from_db()
        self.assertIsNotNone(self.user.identification)
        application.refresh_from_db()
        self.assertEqual('updated', application.id_check_status)
        self.assertEqual('under_review', application.customer_status)
        self.assertEqual('ready_for_action', application.processing_status)
开发者ID:brendanc-dpaw,项目名称:ledger,代码行数:58,代码来源:test_process.py


示例17: ApplicationEntrySecurity

class ApplicationEntrySecurity(TestCase):
    def setUp(self):
        self.client = SocialClient()

    def test_user_access_other_user(self):
        """
        Test that a user cannot edit/view another user application
        """
        customer1 = create_random_customer()
        customer2 = create_random_customer()
        self.assertNotEqual(customer1, customer2)
        application1 = helpers.create_application(user=customer1)
        application2 = helpers.create_application(user=customer2)
        self.assertNotEqual(application1, application2)

        # login as user1
        self.client.login(customer1.email)
        my_url = reverse('applications:enter_details_existing_application',
                         args=[application1.licence_type.code, application1.pk])
        response = self.client.get(my_url)
        self.assertEqual(200, response.status_code)

        forbidden_urls = [
            reverse('applications:edit_application', args=[application2.licence_type.code, application2.pk]),
            reverse('applications:enter_details_existing_application',
                    args=[application2.licence_type.code, application2.pk]),
            reverse('applications:preview', args=[application2.licence_type.code, application2.pk])
        ]

        for forbidden_url in forbidden_urls:
            response = self.client.get(forbidden_url, follow=True)
            self.assertEqual(403, response.status_code)

    def test_user_access_lodged(self):
        """
        Once the application if lodged the user should not be able to edit it
        """
        customer1 = create_random_customer()
        # login as user1
        self.client.login(customer1.email)

        application = helpers.create_application(user=customer1)
        self.assertEqual('draft', application.customer_status)
        my_urls = [
            reverse('applications:edit_application', args=[application.licence_type.code, application.pk]),
            reverse('applications:enter_details_existing_application',
                    args=[application.licence_type.code, application.pk]),
            reverse('applications:preview', args=[application.licence_type.code, application.pk])
        ]
        for url in my_urls:
            response = self.client.get(url, follow=True)
            self.assertEqual(200, response.status_code,
                             msg="Wrong status code {1} for {0}".format(url, response.status_code))

        # lodge the application
        url = reverse('applications:preview', args=[application.licence_type.code, application.pk])
        session = self.client.session
        session['application'] = {
            'profile': application.applicant_profile.pk,
            'data': {
                'project_title': 'Test'
            }
        }
        session.save()
        self.client.post(url)
        application.refresh_from_db()
        self.assertEqual('under_review', application.customer_status)
        for url in my_urls:
            response = self.client.get(url, follow=True)
            self.assertEqual(403, response.status_code)

    def test_user_not_logged_is_redirected_to_login(self):
        """
        A user not logged in should be redirected to the login page and not see a 403
        """
        customer1 = create_random_customer()
        application = helpers.create_application(user=customer1)
        self.assertEqual('draft', application.customer_status)
        my_urls = [
            reverse('applications:edit_application', args=[application.licence_type.code, application.pk]),
            reverse('applications:enter_details_existing_application',
                    args=[application.licence_type.code, application.pk]),
            reverse('applications:preview', args=[application.licence_type.code, application.pk])
        ]
        for url in my_urls:
            response = self.client.get(url, follow=True)
            self.assertEqual(200, response.status_code,
                             msg="Wrong status code {1} for {0}".format(url, response.status_code))
            self.assertTrue(is_login_page(response))

        # lodge the application
        self.client.login(customer1.email)
        url = reverse('applications:preview', args=[application.licence_type.code, application.pk])
        session = self.client.session
        session['application'] = {
            'profile': application.applicant_profile.pk,
            'data': {
                'project_title': 'Test'
            }
        }
#.........这里部分代码省略.........
开发者ID:ropable,项目名称:ledger,代码行数:101,代码来源:test_entry.py


示例18: TestStatusLifeCycle

class TestStatusLifeCycle(TestCase):
    fixtures = ['licences.json']

    def setUp(self):
        self.client = SocialClient()
        self.officer = get_or_create_default_officer()
        self.user = get_or_create_default_customer()
        self.assertNotEqual(self.officer, self.user)

    def tearDown(self):
        self.client.logout()
        clear_mailbox()
        clear_all_id_files()

    def test_id_update(self):
        """
        Test that when an ID update is required and the users update their ID the customer and id status are correctly
         updated
        """
        application = create_and_lodge_application(self.user)
        self.client.login(self.officer.email)
        self.assertTrue(is_client_authenticated(self.client))
        clear_mailbox()
        data = {
            'officer': self.officer.pk,
            'application': application.pk,
            'reason': IDRequest.REASON_CHOICES[0][0],
            'text': 'you to upload an ID.'
        }
        url = reverse('wl_applications:id_request')
        self.assertFalse(is_email())
        response = self.client.post(url, data)
        self.assertEqual(200, response.status_code)
        resp_data = json.loads(response.content.decode('utf8'))
        self.assertIn('id_check_status', resp_data)
        self.assertIn('processing_status', resp_data)
        application.refresh_from_db()
        self.assertEqual('id_required', application.customer_status)
        self.assertEqual('awaiting_update', application.id_check_status)
        self.assertEqual('awaiting_applicant_response', application.processing_status)
        self.assertTrue(is_email())
        email = get_email()
        self.assertIn(application.applicant_profile.email, email.to)
        self.assertEqual(ApplicationIDUpdateRequestedEmail.subject, email.subject)

        # now user upload ID
        self.client.logout()
        self.assertIsNone(self.user.identification)
        self.client.login(self.user.email)
        self.assertTrue(is_client_authenticated(self.client))
        self.client.get(reverse('wl_main:identification'))
        upload_id(self.user)
        self.user.refresh_from_db()
        self.assertIsNotNone(self.user.identification)
        application.refresh_from_db()
        self.assertEqual('updated', application.id_check_status)
        self.assertEqual('under_review', application.customer_status)
        self.assertEqual('ready_for_action', application.processing_status)

    def test_application_amendment(self):
        """
        Test that when an amendment is required, the user receives an email and can amend their application. When the
        user relodged, the officer can see the amendment and set the review status accordingly.
        """
        application = create_and_lodge_application(self.user)
        self.assertFalse(application.can_user_edit)

        self.client.login(self.officer.email)

        post_data = {
            'officer': self.officer.pk,
            'application': application.pk,
            'reason': AmendmentRequest.REASON_CHOICES[0][0],
            'text': 'Application needs more data'
        }

        response = self.client.post(reverse('wl_applications:amendment_request'), post_data)

        self.assertEqual(200, response.status_code)

        resp_data = json.loads(response.content.decode('utf8'))

        application.refresh_from_db()

        self.assertIn('review_status', resp_data)
        self.assertEquals(resp_data['review_status'], utils.REVIEW_STATUSES[application.review_status])
        self.assertIn('processing_status', resp_data)
        self.assertEquals(resp_data['processing_status'], utils.PROCESSING_STATUSES[application.processing_status])

        self.assertEqual(application.customer_status, 'amendment_required')
        self.assertEqual(application.processing_status, 'awaiting_applicant_response')
        self.assertEqual(application.review_status, 'awaiting_amendments')

        amendment_request = AmendmentRequest.objects.filter(application=application).first()

        self.assertIsNotNone(amendment_request)

        self.assertEquals(amendment_request.status, 'requested')

        self.assertTrue(is_email())
#.........这里部分代码省略.........
开发者ID:wilsonc86,项目名称:ledger,代码行数:101,代码来源:test_process.py


示例19: ApplicationEntryTestCase

class ApplicationEntryTestCase(TestCase):
    def setUp(self):
        self.customer = create_default_customer()

        self.client = SocialClient()

        licence_type = WildlifeLicenceType.objects.get(code='regulation17')
        licence_type.identification_required = True
        licence_type.save()

    def tearDown(self):
        self.client.logout()
        # clean id file
        if self.customer.identification:
            os.remove(self.customer.identification.path)

    def test_select_licence_type(self):
        """Testing that a user can display the licence type selection list"""
        self.client.login(self.customer.email)

        # check that client can access the licence type selection list
        response = self.client.get(reverse('applications:select_licence_type'))
        self.assertEqual(200, response.status_code)

    def test_check_identification_required_no_current_id(self):
        """Testing that a user can display the identification required page in the case the user has no
        current identification, and upload an ID.
        """
        self.client.login(self.customer.email)

        # check that client can access the identification required page
        response = self.client.get(reverse('applications:check_identification', args=('regulation17',)))
        self.assertEqual(200, response.status_code)

        with open(TEST_ID_PATH) as fp:
            post_params = {
                'identification_file': fp
            }
            response = self.client.post(reverse('applications:check_identification', args=('regulation17',)),
                                        post_params)

            self.assertRedirects(response, reverse('applications:create_select_profile', args=('regulation17',)),
                                 status_code=302, target_status_code=200, fetch_redirect_response=False)

            # update customer
            self.customer = EmailUser.objects.get(email=self.customer.email)

            # assert customer's ID is the uploaded file
            self.assertEqual(self.customer.identification.filename, 'test_id.jpg')

    def test_check_identification_required_current_id(self):
        """Testing that a user can display the identification required page in the case the user has a
        current identification.
        """
        self.client.login(self.customer.email)

        with open(TEST_ID_PATH) as fp:
            self.customer.identification = Document.objects.create(name='test_id')
            self.customer.identification.file.save('test_id.jpg', File(fp), save=True)
            self.customer.save()

        # check that client is redirected to profile creation / selection page
        response = self.client.get(reverse('applications:check_identification', args=('regulation17',)))
        self.assertRedirects(response, reverse('applications:create_select_profile', args=('regulation17',)),
                             status_code=302, target_status_code=200, fetch_redirect_response=False)

    def test_create_select_profile_create(self):
        """Testing that a user can display the create / select pro 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python decorators.rendered_template函数代码示例发布时间:2022-05-26
下一篇:
Python helpers.is_officer函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap