def test_redirect_to_user_list(self, team_user): url = resolve_url("budget:ApplicationList") response = get_client(team_user).get(url) assert_no_form_errors(response) assert response.status_code == 302 assert response.url == resolve_url("budget:ApplicationListUser", team_user.pk)
def test_post(self, client): item = factories.SharedFileFactory() url = resolve_url('secure_share:SharedFileAuthorize', item.pk) response = client.post(url, data={'password': item.secret}) assert_no_form_errors(response) assert response.status_code == 200 assert "attachment; filename={}".format( item.file.name) == response.get('Content-Disposition') assert item.file.read() == response.content
def test_post(self, team_client, manager): item = factories.ApplicationFactory(manager=manager) url = resolve_url("budget:ApplicationCreate") data = model_to_request_data_dict(item) data['manager'] = item.manager_id response = team_client.post(url, data=data) assert_no_form_errors(response) assert response.status_code == 302 assert models.DecisionKind.manager == models.Application.objects.exclude( pk=item.pk).first().awaiting
def test_post(self, procurement, status): item = factories.ApplicationFactory() url = resolve_url("budget:ApplicationStatus", item.pk) response = get_client(procurement).post(url, data={'status': int(status)}) assert_no_form_errors(response) assert response.status_code == 302 assert response.url == resolve_url( "budget:ApplicationList") + "?approval=true" item.refresh_from_db() assert item.status == status
def test_post(self, client): item = factories.SharedUrlFactory() url = resolve_url('secure_share:SharedUrlAuthorize', item.pk) response = client.post(url, data={'password': item.secret}) assert_no_form_errors(response) assert response.status_code == 302 assert response.url == item.url item.refresh_from_db() assert item.access_counter == 1 client.post(url, data={'password': item.secret}) item.refresh_from_db() assert item.access_counter == 2
def test_reject(self, control_client): item = factories.ApplicationFactory() control = int(models.DecisionKind.control) url = resolve_url("budget:DecisionCreate", item.pk, control) response = control_client.post(url, data={'approval': 'reject'}) assert_no_form_errors(response) item = models.Decision.objects.first() assert response.status_code == 302 assert resolve_url("budget:ApplicationList") == response.url decision = item.application.get_decision(control) assert decision is not None assert decision.approval is False
def test_post(self, send_approval_request, accountant, manager): item = factories.ApplicationFactory(manager=manager) url = resolve_url("budget:ApplicationUpdate", item.pk) data = model_to_request_data_dict(item) data['manager'] = item.manager_id response = get_client(item.requester).post(url, data=data) assert_no_form_errors(response) assert response.status_code == 302 assert send_approval_request.called assert send_approval_request.call_count == 1 args, kwargs = send_approval_request.call_args assert manager == args[0]
def test_manager(self, manager, accountant): item = factories.ApplicationFactory(manager=manager) url = resolve_url("budget:ApplicationCreate") data = model_to_request_data_dict(item) data['manager'] = item.manager_id response = get_client(manager).post(url, data=data) assert_no_form_errors(response) assert response.status_code == 302 application = models.Application.objects.exclude(pk=item.pk).first() assert models.DecisionKind.accountant == application.awaiting assert application.decisions.count() == 1 decision = application.decisions.first() assert decision.user == manager assert decision.approval is True
def test_approve(self, control_client): waiting = factories.DecisionFactory( kind=models.DecisionKind.accountant, application__account=factories.AccountFactory()).application item = factories.ApplicationFactory(account=factories.AccountFactory()) control = int(models.DecisionKind.control) url = resolve_url("budget:DecisionCreate", item.pk, control) response = control_client.post(url, data={'approval': 'approve'}) assert_no_form_errors(response) assert response.status_code == 302 assert response.url == resolve_url("budget:DecisionCreate", waiting.pk, control) decision = item.get_decision(control) assert decision is not None assert decision.approval is True