122 |
122 |
assert importer.errors == [LineError('unknown-flag', line=1, column=2)]
|
123 |
123 |
|
124 |
124 |
|
125 |
|
def test_missing_key_column_error(profile, user_csv_importer_factory):
|
126 |
|
importer = user_csv_importer_factory('email,first_name\n1,2')
|
|
125 |
def test_missing_key_column_error(profile, user_csv_importer_factory, settings):
|
|
126 |
content = 'email,first_name\ntnoel@entrouvert.com,Thomas'
|
|
127 |
importer = user_csv_importer_factory(content)
|
|
128 |
assert not importer.run()
|
|
129 |
assert importer.has_errors
|
|
130 |
assert importer.errors == [Error('missing-key-column')]
|
|
131 |
|
|
132 |
ou = get_default_ou()
|
|
133 |
ou.email_is_unique = True
|
|
134 |
ou.save()
|
|
135 |
|
|
136 |
importer = user_csv_importer_factory(content)
|
|
137 |
assert importer.run()
|
|
138 |
assert not importer.has_errors
|
|
139 |
|
|
140 |
content = 'username,first_name\ntnoel,Thomas'
|
|
141 |
|
|
142 |
importer = user_csv_importer_factory(content)
|
|
143 |
assert importer.run()
|
|
144 |
assert not importer.has_errors
|
|
145 |
|
|
146 |
settings.A2_USERNAME_IS_UNIQUE = False
|
|
147 |
importer = user_csv_importer_factory(content)
|
|
148 |
assert not importer.run()
|
|
149 |
assert importer.has_errors
|
|
150 |
assert importer.errors == [Error('missing-key-column')]
|
|
151 |
|
|
152 |
content = 'last_name,first_name\nNoel,Thomas'
|
|
153 |
importer = user_csv_importer_factory(content)
|
127 |
154 |
assert not importer.run()
|
128 |
155 |
assert importer.has_errors
|
129 |
156 |
assert importer.errors == [Error('missing-key-column')]
|
130 |
|
-
|