Created
March 13, 2022 00:52
-
-
Save giovannicimolin/9cca3e4cd9f732c48b19228727d19786 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest.mock import patch | |
from django.urls import reverse | |
from django.contrib.auth import get_user_model | |
from rest_framework import status | |
from rest_framework.test import APITestCase | |
User = get_user_model() | |
class BulkImportTestCase(APITestCase): | |
def setUp(self): | |
super().setUp() | |
self.superuser = User.objects.create_superuser('admin', 'admin@example.com', 'admin') | |
self.client.login(username='admin', password='admin') | |
@patch("emissions.views.import_fully_processed_emissions") | |
def test_import_fully_processed_emissions(self, mock): | |
""" | |
Test processed emissions import mechanism. | |
""" | |
mock.return_value = 2 | |
url = reverse('emissions-bulk-import', kwargs={"import_type": "FULLY_PROCESSED_EMISSIONS"}) | |
with open('emissions/test/assets/fully_processed_emissions.csv') as file: | |
response = self.client.post(url, {'file': file}) | |
import pdb; pdb.set_trace() | |
self.assertEqual(response.status_code, 201) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment