(core) updates from grist-core

pull/349/head
Paul Fitzpatrick 2 years ago
commit b29ce996b6

@ -1,6 +1,6 @@
{
"name": "grist-core",
"version": "1.0.3",
"version": "1.0.4",
"license": "Apache-2.0",
"description": "Grist is the evolution of spreadsheets",
"homepage": "https://github.com/gristlabs/grist-core",

@ -52,7 +52,7 @@ def _is_numeric(text):
try:
t(text)
return True
except (ValueError, OverflowError):
except (ValueError, OverflowError, TypeError):
pass
return False
@ -63,7 +63,7 @@ def _is_header(header, data_rows):
"""
# See if the row has any non-text values.
for cell in header:
if not isinstance(cell, six.string_types) or _is_numeric(cell):
if not (isinstance(cell, six.string_types) or cell is None) or _is_numeric(cell):
return False
@ -109,7 +109,7 @@ def expand_headers(headers, data_offset, rows):
row_length = max(itertools.chain([len(headers)],
(_count_nonempty(r) for r in itertools.islice(rows, data_offset,
None))))
header_values = [h.strip() for h in headers] + [u''] * (row_length - len(headers))
header_values = [h.strip() if h else '' for h in headers] + [u''] * (row_length - len(headers))
return header_values

@ -105,17 +105,17 @@ class TestImportXLS(unittest.TestCase):
'table_name': u'Transaction Report',
'column_metadata': [
{'type': 'Any', 'id': u''},
{'type': 'Any', 'id': u''},
{'type': 'Numeric', 'id': u'Start'},
{'type': 'Numeric', 'id': u''},
{'type': 'Numeric', 'id': u''},
{'type': 'Any', 'id': u''},
{'type': 'Any', 'id': u'Seek no easy ways'},
],
'table_data': [
['', u'SINGLE MERGED', u'The End'],
['Start', '1637384.52', ''],
[None, 2444344.06, None],
[None, 2444344.06, None],
['Seek no easy ways', u'', u''],
[u'SINGLE MERGED', u'The End'],
[1637384.52, None],
[2444344.06, None],
[2444344.06, None],
[u'', u''],
],
}])
@ -225,6 +225,25 @@ class TestImportXLS(unittest.TestCase):
],
}])
def test_header_with_none_cell(self):
parsed_file = import_xls.parse_file(*_get_fixture('test_headers_with_none_cell.xlsx'))
tables = parsed_file[1]
self.assertEqual(tables, [{
'table_name': 'Sheet1',
'column_metadata': [
{'id': u'header1', 'type': 'Any'},
{'id': u'header2', 'type': 'Any'},
{'id': u'header3', 'type': 'Any'},
{'id': u'header4', 'type': 'Any'},
],
'table_data': [
['foo1', 'foo2'],
['bar1', 'bar2'],
['baz1', 'baz2'],
['boz1', 'boz2'],
],
}])
if __name__ == '__main__':
unittest.main()

@ -128,14 +128,14 @@ describe("Localization", function() {
try {
// Wrong path to locales.
process.env.GRIST_LOCALES_DIR = __filename;
await assert.isRejected(server.restart());
await assert.isRejected(server.restart(false, true));
// Empty folder.
const tempDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'grist_test_'));
process.env.GRIST_LOCALES_DIR = tempDirectory;
await assert.isRejected(server.restart());
await assert.isRejected(server.restart(false, true));
// Wrong file format.
fs.writeFileSync(path.join(tempDirectory, 'dummy.json'), 'invalid json');
await assert.isRejected(server.restart());
await assert.isRejected(server.restart(false, true));
} finally {
oldEnv.restore();
await server.restart();

@ -877,11 +877,13 @@ async function testChoices(colA: string = 'Left', colB: string = 'Right') {
if (await getColumnType() === 'Choice List') {
await gu.sendKeys(Key.ENTER);
}
await gu.waitForServer();
await gu.getCell(colB, 1).click();
await gu.sendKeys("one", Key.ENTER);
if (await getColumnType() === 'Choice List') {
await gu.sendKeys(Key.ENTER);
}
await gu.waitForServer();
// Rename one of the choices.
await selectColumns(colA, colB);
const undo = await gu.begin();
@ -941,6 +943,7 @@ const choiceEditor = {
},
async save() {
await driver.find(".test-choice-list-entry-save").click();
await gu.waitForServer();
},
async cancel() {
await driver.find(".test-choice-list-entry-cancel").click();
@ -1023,12 +1026,14 @@ async function wrap(state?: boolean) {
if (await buttons[0].matches('[class*=-selected]')) {
if (state === false) {
await buttons[0].click();
await gu.waitForServer();
return false;
}
return true;
}
if (state === true) {
await buttons[0].click();
await gu.waitForServer();
return true;
}
return false;
@ -1106,6 +1111,7 @@ async function alignment(value?: 'left' | 'right' | 'center') {
if (value === 'right') {
await buttons[2].click();
}
await gu.waitForServer();
return;
}
if (await buttons[0].matches('[class*=-selected]')) {
@ -1293,6 +1299,7 @@ async function numMode(value?: 'currency' | 'percent' | 'exp' | 'decimal') {
await driver.findContent('.test-numeric-mode .test-select-button', /Exp/).click();
}
}
await gu.waitForServer();
}
if (mode.length === 0) {
return undefined;

@ -55,7 +55,7 @@ export class TestServerMerged implements IMochaServer {
* Restart the server. If reset is set, the database is cleared. If reset is not set,
* the database is preserved, and the temporary directory is unchanged.
*/
public async restart(reset: boolean = false) {
public async restart(reset: boolean = false, quiet = false) {
if (this.isExternalServer()) { return; }
if (this._starts > 0) {
this.resume();
@ -97,7 +97,6 @@ export class TestServerMerged implements IMochaServer {
const serverLog = process.env.VERBOSE ? 'inherit' : nodeLogFd;
const env: Record<string, string> = {
TYPEORM_DATABASE: this._getDatabaseFile(),
TEST_CLEAN_DATABASE: reset ? 'true' : '',
GRIST_DATA_DIR: this.testDocDir,
GRIST_INST_DIR: this.testDir,
// uses the test installed plugins folder as the user installed plugins.
@ -129,6 +128,7 @@ export class TestServerMerged implements IMochaServer {
// This skips type-checking when running server, but reduces startup time a lot.
TS_NODE_TRANSPILE_ONLY: 'true',
...process.env,
TEST_CLEAN_DATABASE: reset ? 'true' : '',
};
if (!process.env.REDIS_URL) {
// Multiple doc workers only possible when redis is available.
@ -137,7 +137,7 @@ export class TestServerMerged implements IMochaServer {
}
this._server = spawn('node', [cmd], {
env,
stdio: ['inherit', serverLog, serverLog],
stdio: quiet ? 'ignore' : ['inherit', serverLog, serverLog],
});
this._exitPromise = exitPromise(this._server);
@ -147,7 +147,7 @@ export class TestServerMerged implements IMochaServer {
// Try to be more helpful when server exits by printing out the tail of its log.
this._exitPromise.then((code) => {
if (this._server.killed) { return; }
if (this._server.killed || quiet) { return; }
log.error("Server died unexpectedly, with code", code);
const output = execFileSync('tail', ['-30', nodeLogPath]);
log.info(`\n===== BEGIN SERVER OUTPUT ====\n${output}\n===== END SERVER OUTPUT =====`);

Loading…
Cancel
Save