markupsafe.escape(qualified_table)))
return (schema, table)
- def report_bad_cols(self, qualified_table, bad_cols, quotecols):
- if quotecols:
- detail = ('<p>The following columns are not in the ({0})'
- ' table, or the first line of your file is not'
- ' in the expected format and your column names'
- ' have merged (all the names appear in a single'
- ' list item, below), or the supplied column names'
- ' do not match'
- " the character case of the table's columns,"
- ' or you do not have permission to access'
- ' the columns:</p><ul>')
- else:
- detail = ('<p>The following columns are not in the ({0})'
- ' table, or the first line of your file is not'
- ' in the expected format and your column names'
- ' have merged (all the names appear in a single'
- ' list item, below), '
- ' or the table has column names containing'
- ' upper case characters, or you do not have'
- ' permission to access the columns:</p><ul>')
- detail = detail.format(markupsafe.escape(qualified_table))
-
- for bad_col in bad_cols:
- detail += '<li>{0}</li>'.format(markupsafe.escape(bad_col))
- detail += '</ul>'
- raise upload_ex.BadHeadersError(
- 'Header line contains unknown column names',
- detail=detail)
-
def get_column_quoter(self, quotecols):
if quotecols:
return doublequote
stmt = attrs.field(default=None)
cols = attrs.field(default=None)
+ def report_bad_cols(self, qualified_table, bad_cols, quotecols):
+ if quotecols:
+ detail = ('<p>The following columns are not in the ({0})'
+ ' table, or the first line of your file is not'
+ ' in the expected format and your column names'
+ ' have merged (all the names appear in a single'
+ ' list item, below), or the supplied column names'
+ ' do not match'
+ " the character case of the table's columns,"
+ ' or you do not have permission to access'
+ ' the columns:</p><ul>')
+ else:
+ detail = ('<p>The following columns are not in the ({0})'
+ ' table, or the first line of your file is not'
+ ' in the expected format and your column names'
+ ' have merged (all the names appear in a single'
+ ' list item, below), '
+ ' or the table has column names containing'
+ ' upper case characters, or you do not have'
+ ' permission to access the columns:</p><ul>')
+ detail = detail.format(markupsafe.escape(qualified_table))
+
+ for bad_col in bad_cols:
+ detail += '<li>{0}</li>'.format(markupsafe.escape(bad_col))
+ detail += '</ul>'
+ raise upload_ex.BadHeadersError(
+ 'Header line contains unknown column names',
+ detail=detail)
+
def build_insert_stmt(
self, tuh, data, qualified_table, quotecols, column_quoter):
'''tuh: A TableUploadHandler'''
assert True
-# BaseTableUploadHandler.report_bad_cols()
-
-@pytest.mark.parametrize(
- ('quotecols',), [
- (True,),
- (False,)])
-def test_report_bad_cols(mock_escape, quotecols):
- '''The expected exception is raised
- '''
-
- request = DummyRequest()
- uh = upload.BaseTableUploadHandler(request)
- with pytest.raises(upload_ex.BadHeadersError):
- uh.report_bad_cols(None, ['col1', 'col2'], quotecols)
-
- assert True
-
-
# BaseTableUploadHandler.factory()
@pytest.mark.unittest
assert uh.ue == ue
assert uh.cur == sample_cursor
+
+
+# InsertStmt.report_bad_cols()
+
+@pytest.mark.parametrize(
+ ('quotecols',), [
+ (True,),
+ (False,)])
+def test_report_bad_cols(mock_escape, quotecols):
+ '''The expected exception is raised
+ '''
+ insert_stmt = upload.InsertStmt()
+ with pytest.raises(upload_ex.BadHeadersError):
+ insert_stmt.report_bad_cols(None, ['col1', 'col2'], quotecols)
+
+ assert True