manager: allow execute from simulation in csv import (#50159)
This commit is contained in:
parent
534df33bbd
commit
7aa260def8
|
@ -59,6 +59,14 @@
|
|||
<td>{% trans "value has errors" %}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% if report.simulate %}
|
||||
<form action="{% url 'a2-manager-users-import' uuid=user_import.uuid %}" method="post" id="action-form">
|
||||
{% csrf_token %}
|
||||
<div class="buttons">
|
||||
<button name="execute">{% trans "Execute" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</aside>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -725,6 +725,42 @@ def test_manager_create_user_next(superuser_or_admin, app, ou1):
|
|||
assert urlparse(response.location).path == next_url.replace('$UUID', str(user.uuid))
|
||||
|
||||
|
||||
def test_user_import_execute_from_simutation(transactional_db, app, admin):
|
||||
csv_content = '''first_name key,last_name
|
||||
Elliott,3'''
|
||||
response = login(app, admin, '/manage/users/')
|
||||
|
||||
response = response.click('Import users')
|
||||
index = [i for i in response.forms if 'import_file' in response.forms[i].fields][0]
|
||||
response.forms[index].set(
|
||||
'import_file',
|
||||
Upload('users.csv', csv_content.encode('utf-8'), 'application/octet-stream'))
|
||||
response.forms[index].set('encoding', 'utf-8-sig')
|
||||
response.forms[index].set('ou', str(get_default_ou().pk))
|
||||
response = response.forms[index].submit().follow()
|
||||
response = response.forms['action-form'].submit(name='simulate').follow()
|
||||
|
||||
start = time.time()
|
||||
response = response.click('Users Import')
|
||||
while 'Running' in response.text:
|
||||
response = response.click('Users Import')
|
||||
assert time.time() - start < 2
|
||||
time.sleep(.1)
|
||||
|
||||
urls = re.findall('<a href="(/manage/users/import/[^/]+/[^/]+/)">', response.text)
|
||||
response = app.get(urls[0])
|
||||
|
||||
assert not User.objects.filter(first_name='Elliott').exists()
|
||||
|
||||
response = response.form.submit(name='execute').follow()
|
||||
while 'Running' in response.text:
|
||||
response = response.click('Users Import')
|
||||
assert time.time() - start < 2
|
||||
time.sleep(.1)
|
||||
|
||||
assert User.objects.filter(first_name='Elliott').exists()
|
||||
|
||||
|
||||
def test_manager_create_user_next_form_error(superuser_or_admin, app, ou1):
|
||||
next_url = u'/example.nowhere.null/'
|
||||
url = u'/manage/users/%s/add/?next=%s' % (ou1.pk, next_url)
|
||||
|
|
Loading…
Reference in New Issue