def test_invalid_column_names(self): test_users = """\ user_key|username|invalid_col 1|fred|value """ csv_data = io.StringIO(dedent(test_users)) user_data = csv.DictReader(csv_data, delimiter='|') importer = BlackboardImport('ignore.zip', self.offering) with self.assertRaises(LMSImportFileError): importer._process_users(user_data)
def test_valid_data(self): test_users = """\ user_key|username|firstname|lastname|email 1|fred|Fred|Jones|[email protected] """ csv_data = io.StringIO(dedent(test_users)) user_data = csv.DictReader(csv_data, delimiter='|') importer = BlackboardImport('ignore.zip', self.offering) importer._process_users(user_data) self.assertTrue( LMSUser.objects.filter(lms_user_id=1, username='******', firstname='Fred', lastname='Jones', email='*****@*****.**', course_offering=self.offering).exists())