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

[Draft] Bulkupdate integration test #407

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
33 changes: 33 additions & 0 deletions rorapi/tests/tests_integration/tests_bulkupdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import io
import os
import requests
from django.test import SimpleTestCase
from unittest.mock import patch

BASE_URL = '{}/v2/organizations'.format(
os.environ.get('ROR_BASE_URL', 'http://localhost')
)

class APIBulkUpdateTestCase(SimpleTestCase):

def setUp(self):
os.environ["ROUTE_USER"] = "test_user"
os.environ["TOKEN"] = "test_token"

@patch('rorapi.common.views.OurTokenPermission.has_permission', return_value=True)
def test_bulk_update(self, mock_permission):
csv_data = """id,name,description
12345,Updated Organization,Updated description.
"""
csv_file = io.StringIO(csv_data)

headers = {
'Token': 'test_token',
'Route-User': 'test_user'
}

response = requests.post(BASE_URL, headers=headers, files={'file': ('bulk_update.csv', csv_file.getvalue())})

self.assertEqual(response.status_code, 201)
output = response.json()
self.assertIn('Successfully processed', output)