Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTD-4896 Add basic CSV upload functionality #1897

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions caseworker/external_data/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.urls import reverse
from django.views.generic import TemplateView
from django.views.generic.edit import FormView, CreateView
from django.http import Http404

from core.auth.views import LoginRequiredMixin

Expand All @@ -19,12 +18,9 @@
class DenialUploadView(LoginRequiredMixin, SuccessMessageMixin, CreateView):
template_name = "external_data/denial-upload.html"
form_class = forms.DenialUploadForm
success_message = "Denials created successfully"
success_message = "Denials created or updated successfully"
extra_context = {"base_64_csv": base_64_csv}

def dispatch(self, request, *args, **kwargs):
raise Http404("CSV denials uploads have been disabled")

def form_valid(self, form):
response = services.upload_denials(request=self.request, data=form.cleaned_data)
if not response.ok:
Expand Down
22 changes: 0 additions & 22 deletions unit_tests/caseworker/external_data/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,6 @@ def mock_denial_patch(requests_mock):
yield requests_mock.patch(url=url, json={})


def test_upload_denial_404(authorized_client, mock_denial_upload, settings):
# given the case has activity from system user
url = reverse(
"external_data:denials-add-by-csv"
) # TODO: rename back to ""denials-upload" when we are ready to release this to users

file_path = os.path.join(settings.BASE_DIR, "caseworker/external_data/example.csv")
data = {"csv_file": open(file_path, "rb")}

# when the case is viewed
response = authorized_client.post(url, data, format="multipart")

# then it does not error
assert response.status_code == 404
# and the upstream endpoint was posted

response = authorized_client.get(url)
assert response.status_code == 404


@pytest.mark.skip(reason="CSV denials upload has been disabled")
def test_upload_denial_valid_file(authorized_client, mock_denial_upload, settings):
# given the case has activity from system user
url = reverse(
Expand All @@ -81,7 +60,6 @@ def test_upload_denial_valid_file(authorized_client, mock_denial_upload, setting
assert mock_denial_upload.last_request.json() == {"csv_file": f.read()}


@pytest.mark.skip(reason="CSV denials upload has been disabled")
def test_upload_denial_invalid_file(authorized_client, mock_denial_upload_validation_error, settings):
# given the case has activity from system user
url = reverse(
Expand Down
Loading