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_control_as_manager(self, control): item = factories.ApplicationFactory(manager=control) url = resolve_url("budget:ApplicationDetail", item.pk) response = get_client(control).get(url) assert response.status_code == 302 assert response.url == resolve_url("budget:DecisionCreate", item.pk, int(models.DecisionKind.manager))
def test_control_as_manager(self, control, accountant): item = factories.ApplicationFactory(manager=control) url = resolve_url("budget:DecisionCreate", item.pk, int(models.DecisionKind.manager)) response = get_client(control).post(url, data={'approval': 'approve'}) assert response.status_code == 302 assert item.decisions.filter( kind=models.DecisionKind.manager).first() is not None assert item.decisions.filter( kind=models.DecisionKind.control).first() is None
def test_with_decissions(self, kind, approval, ok, team_user): decission = factories.DecisionFactory( kind=kind, approval=approval, application__requester=team_user, ) url = resolve_url("budget:ApplicationAccount", decission.application.pk) response = get_client(team_user).get(url) assert response.status_code == 200 assert len(response.context_data['messages']) == 0
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_with_decisions(self, team_user): decission = factories.DecisionFactory( kind=models.DecisionKind.manager, application__requester=team_user, ) url = resolve_url("budget:ApplicationUpdate", decission.application.pk) response = get_client(team_user).get(url) assert response.status_code == 200 messages = [m.message for m in response.context_data['messages']] msg = messages[0] log.debug("msg: %s", msg) assert msg.startswith('Zmiana zapotrzebowania skutkuje')
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_manager(self): item = factories.ApplicationFactory() url = resolve_url("budget:DecisionCreate", item.pk, int(models.DecisionKind.manager)) response = get_client(item.manager).get(url) assert response.status_code == 200
def test_get(self, team_user): url = resolve_url("budget:ApplicationListUser", team_user.pk) response = get_client(team_user).get(url) assert response.status_code == 200
def test_get(self, team_user): url = resolve_url("budget:ApplicationStatus", 666) response = get_client(team_user).get(url) assert response.status_code == 403
def test_accountant_get(self, accountant): item = factories.ApplicationFactory() url = resolve_url("budget:ApplicationUpdate", item.pk) response = get_client(accountant).get(url) assert response.status_code == 200
def test_get(self, team_user): item = factories.ApplicationFactory(requester=team_user) url = resolve_url("budget:ApplicationUpdate", item.pk) response = get_client(team_user).get(url) assert response.status_code == 200 assert len(response.context_data['messages']) == 0