712 |
712 |
assert urlparse(response.location).path == next_url.replace('$UUID', str(user.uuid))
|
713 |
713 |
|
714 |
714 |
|
|
715 |
def test_user_import_execute_from_simutation(transactional_db, app, admin):
|
|
716 |
csv_content = '''first_name key,last_name
|
|
717 |
Elliott,3'''
|
|
718 |
response = login(app, admin, '/manage/users/')
|
|
719 |
|
|
720 |
response = response.click('Import users')
|
|
721 |
index = [i for i in response.forms if 'import_file' in response.forms[i].fields][0]
|
|
722 |
response.forms[index].set(
|
|
723 |
'import_file',
|
|
724 |
Upload('users.csv', csv_content.encode('utf-8'), 'application/octet-stream'))
|
|
725 |
response.forms[index].set('encoding', 'utf-8-sig')
|
|
726 |
response.forms[index].set('ou', str(get_default_ou().pk))
|
|
727 |
response = response.forms[index].submit().follow()
|
|
728 |
response = response.forms['action-form'].submit(name='simulate').follow()
|
|
729 |
|
|
730 |
start = time.time()
|
|
731 |
response = response.click('Users Import')
|
|
732 |
while 'Running' in response.text:
|
|
733 |
response = response.click('Users Import')
|
|
734 |
assert time.time() - start < 2
|
|
735 |
time.sleep(.1)
|
|
736 |
|
|
737 |
urls = re.findall('<a href="(/manage/users/import/[^/]+/[^/]+/)">', response.text)
|
|
738 |
response = app.get(urls[0])
|
|
739 |
|
|
740 |
assert not User.objects.filter(first_name='Elliott').exists()
|
|
741 |
|
|
742 |
response = response.form.submit(name='execute').follow()
|
|
743 |
while 'Running' in response.text:
|
|
744 |
response = response.click('Users Import')
|
|
745 |
assert time.time() - start < 2
|
|
746 |
time.sleep(.1)
|
|
747 |
|
|
748 |
assert User.objects.filter(first_name='Elliott').exists()
|
|
749 |
|
|
750 |
|
715 |
751 |
def test_manager_create_user_next_form_error(superuser_or_admin, app, ou1):
|
716 |
752 |
next_url = u'/example.nowhere.null/'
|
717 |
753 |
url = u'/manage/users/%s/add/?next=%s' % (ou1.pk, next_url)
|
718 |
|
-
|