@datagrok/api-tests
Advanced tools
Comparing version 1.7.4 to 1.7.5
@@ -1,2 +0,2 @@ | ||
var apitests;(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{dummyDataFrameFunction:()=>N,dummyPackageFunction:()=>y,expectTable:()=>d,getColumn:()=>m,getDT:()=>p,getTable:()=>f,testCustomFilter:()=>s,testViewerForProperties:()=>l});const n=grok,r=DG;class o extends r.JsViewer{constructor(){super(),this.field="field value",this.onTableAttachedCounter=0,this.testPropertyString=this.string("testPropertyString",""),this.testPropertyInt=this.int("testPropertyInt",-1)}onTableAttached(){super.onTableAttached(),this.onTableAttachedCounter++}}class u extends r.Filter{get filterSummary(){return""}constructor(){super()}applyState(t){if("string"==typeof t.column||t.column instanceof String){const e=t.column;delete t.column,t.columnName=e}super.applyState(t)}applyFilter(){}}var i;function a(t,e=!0,n){if(n=n?`${n}, `:"",t!==e)throw new Error(`${n}Expected "${e}", got "${t}"`)}function c(t,e,n=.001,r){if(t===Number.POSITIVE_INFINITY&&e===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY&&e===Number.NEGATIVE_INFINITY||t===Number.NaN&&e===Number.NaN||isNaN(t)&&isNaN(e))return;const o=Math.abs(t-e)<n;if(a(o,!0,`${null!=r?r:""} (tolerance = ${n})`),!o)throw new Error(`Expected ${e}, got ${t} (tolerance = ${n})`)}!function(t){t.notNull=function(t,e){if(null==t)throw new Error(`${null==e?"Value":e} not defined`)}}(i||(i={}));function l(){return new o}function s(){return new u}function f(t,e){return o=this,u=void 0,a=function*(){const o=(yield n.dapi.files.list(e?`system:appdata/${e}/`:"Demo:Files/",!0,t))[0],u=yield o.readAsString();return r.DataFrame.fromCsv(u)},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{c(a.next(t))}catch(t){e(t)}}function r(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var o;e.done?t(e.value):(o=e.value,o instanceof i?o:new i((function(t){t(o)}))).then(n,r)}c((a=a.apply(o,u||[])).next())}));var o,u,i,a}function m(t,e){return t.getCol(e)}function p(t=20,e="demog"){return n.data.demo.getDemoTable(e,t)}function d(t,e){return function(t,e,n){const o=e.rowCount;a(t.rowCount,o,", row count");for(const u of e.columns){const e=t.columns.byName(u.name);if(null==e)throw new Error(`Column ${u.name} not found`);if(e.type!=u.type)throw new Error(`Column ${u.name} type expected ${u.type} got ${e.type}`);for(let t=0;t<o;t++){const o=u.get(t),i=e.get(t);u.type==r.TYPE.FLOAT?c(i,o,1e-4,n):u.type==r.TYPE.DATE_TIME?a(i.isSame(o),!0,n):a(i,o,n)}}}(t,e),!0}function y(t,e){return t+e}function N(t){return{tableOut:t,count:t.rowCount}}apitests=e})(); | ||
var apitests;(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{dummyDataFrameFunction:()=>s,dummyPackageFunction:()=>m,expectTable:()=>f,getColumn:()=>c,getDT:()=>l,getTable:()=>i});const n=grok,o=DG;var r;function u(e,t=!0,n){if(n=n?`${n}, `:"",e!==t)throw new Error(`${n}Expected "${t}", got "${e}"`)}function a(e,t,n=.001,o){if(e===Number.POSITIVE_INFINITY&&t===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY&&t===Number.NEGATIVE_INFINITY||e===Number.NaN&&t===Number.NaN||isNaN(e)&&isNaN(t))return;const r=Math.abs(e-t)<n;if(u(r,!0,`${null!=o?o:""} (tolerance = ${n})`),!r)throw new Error(`Expected ${t}, got ${e} (tolerance = ${n})`)}!function(e){e.notNull=function(e,t){if(null==e)throw new Error(`${null==t?"Value":t} not defined`)}}(r||(r={}));function i(e,t){return r=this,u=void 0,i=function*(){const r=(yield n.dapi.files.list(t?`system:appdata/${t}/`:"Demo:Files/",!0,e))[0],u=yield r.readAsString();return o.DataFrame.fromCsv(u)},new((a=void 0)||(a=Promise))((function(e,t){function n(e){try{c(i.next(e))}catch(e){t(e)}}function o(e){try{c(i.throw(e))}catch(e){t(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof a?r:new a((function(e){e(r)}))).then(n,o)}c((i=i.apply(r,u||[])).next())}));var r,u,a,i}function c(e,t){return e.getCol(t)}function l(e=20,t="demog"){return n.data.demo.getDemoTable(t,e)}function f(e,t){return function(e,t,n){const r=t.rowCount;u(e.rowCount,r,", row count");for(const i of t.columns){const t=e.columns.byName(i.name);if(null==t)throw new Error(`Column ${i.name} not found`);if(t.type!=i.type)throw new Error(`Column ${i.name} type expected ${i.type} got ${t.type}`);for(let e=0;e<r;e++){const r=i.get(e),c=t.get(e);i.type==o.TYPE.FLOAT?a(c,r,1e-4,n):i.type==o.TYPE.DATE_TIME?u(c.isSame(r),!0,n):u(c,r,n)}}}(e,t),!0}function m(e,t){return e+t}function s(e){return{tableOut:e,count:e.rowCount}}apitests=t})(); | ||
//# sourceMappingURL=package.js.map |
{ | ||
"name": "@datagrok/api-tests", | ||
"friendlyName": "API Tests", | ||
"version": "1.7.4", | ||
"version": "1.7.5", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Anna Muzychyna", |
@@ -1,8 +0,8 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import * as ui from 'datagrok-api/ui'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {_package} from '../package-test'; | ||
category('Dapi: files', () => { | ||
@@ -17,8 +17,8 @@ const filePrefix = 'System:AppData/ApiTests/'; | ||
test('Dapi: files - exists', async () => { | ||
test('exists', async () => { | ||
if (!await grok.dapi.files.exists(testTextFilePath)) | ||
throw 'File doesn\'t exist'; | ||
throw new Error('File doesn\'t exist'); | ||
}); | ||
test('Dapi: files - write/read text', async () => { | ||
test('write/read text', async () => { | ||
const filePath = filePrefix + 'Dapi. files - write, read text.txt'; | ||
@@ -30,3 +30,3 @@ const fileText = 'testString'; | ||
if (fileText !== await grok.dapi.files.readAsText(filePath)) | ||
throw 'Сontent is wrong'; | ||
throw new Error('Сontent is wrong'); | ||
} finally { | ||
@@ -37,3 +37,3 @@ await grok.dapi.files.delete(filePath); | ||
test('Dapi: files - write/read blob', async () => { | ||
test('write/read blob', async () => { | ||
const filePath = filePrefix + 'Dapi. files - write, read blob.txt'; | ||
@@ -45,3 +45,3 @@ const content = [0, 1, 2, 3]; | ||
if (content.toString() !== (await grok.dapi.files.readAsBytes(filePath)).toString()) | ||
throw 'Сontent is wrong'; | ||
throw new Error('Сontent is wrong'); | ||
} finally { | ||
@@ -52,8 +52,8 @@ await grok.dapi.files.delete(filePath); | ||
test('Dapi: files - search', async () => { | ||
test('search', async () => { | ||
if ((await grok.dapi.files.list(filePrefix, false, testTextFileName)).length !== 1) | ||
throw 'Can\'t find the file'; | ||
throw new Error('Can\'t find the file'); | ||
}); | ||
test('Dapi: package files', async () => { | ||
test('package files', async () => { | ||
const files = await _package.files.list('datasets', false, 'csv'); | ||
@@ -64,4 +64,4 @@ expect(files.length > 0, true); | ||
// test('Dapi: files - move', async () => { | ||
// let fileName = 'Dapi: files - move.txt'; | ||
// test('move', async () => { | ||
// let fileName = 'move.txt'; | ||
// let filePath = filePrefix + fileName; | ||
@@ -82,3 +82,3 @@ // let newFilePrefix = 'texts'; | ||
test('Dapi: files - delete', async () => { | ||
test('delete', async () => { | ||
const filePath = filePrefix + 'Dapi. files - delete.txt'; | ||
@@ -91,3 +91,3 @@ | ||
if (await grok.dapi.files.exists(filePath)) | ||
throw 'File exists'; | ||
throw new Error('File exists'); | ||
} finally { | ||
@@ -99,3 +99,3 @@ if (await grok.dapi.files.exists(filePath)) | ||
test('Dapi: files - readBinaryDataFrames', async () => { | ||
test('readBinaryDataFrames', async () => { | ||
const dfList = await _package.files.readBinaryDataFrames('datasets/country-languages.d42'); | ||
@@ -110,1 +110,13 @@ expect(dfList.length, 1); | ||
}); | ||
category('Dapi: files: formats', () => { | ||
const extensions = ['csv', 'd42', 'json', 'tar', 'tar.gz', 'tsv', 'txt', 'xlsx', 'xml', 'zip']; //kml, kmz | ||
for (const ext of extensions) { | ||
test(ext, async () => { | ||
const df = await grok.data.files.openTable('System:AppData/ApiTests/datasets/formats/cars.' + ext); | ||
expect(df.rowCount, 10, 'wrong rows number'); | ||
expect(df.columns.length, 10, 'wrong columns number'); | ||
}); | ||
} | ||
}); |
@@ -6,28 +6,4 @@ /* Do not change these import lines. Datagrok will import API library in exactly the same manner */ | ||
import {TestViewerForProperties} from './viewers/test-viewer-for-properties'; | ||
import {TestCustomFilter} from './viewers/test-custom-filter'; | ||
import {expectTable as _expectTable} from '@datagrok-libraries/utils/src/test'; | ||
// -- Viewers -- | ||
//name: TestViewerForProperties | ||
//description: Viewer to test properties and others | ||
//tags: viewer, panel | ||
//output: viewer result | ||
export function testViewerForProperties() { | ||
return new TestViewerForProperties(); | ||
} | ||
// -- Filters -- | ||
//name: testCustomFilter | ||
//description: Test custom filter | ||
//tags: filter | ||
//output: filter result | ||
export function testCustomFilter(): DG.Filter { | ||
const flt: TestCustomFilter = new TestCustomFilter(); | ||
return flt; | ||
} | ||
//name: getTable | ||
@@ -34,0 +10,0 @@ //input: string name |
@@ -1,21 +0,8 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import * as ui from 'datagrok-api/ui'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
import {_package} from "../package-test"; | ||
import {_package} from '../package-test'; | ||
category('ML', () => { | ||
// test('Apply Model', async () => { | ||
// const data = grok.data.demo.demog(); | ||
// const resultDf = await grok.ml.applyModel( | ||
// // 'Demo:PredictSexByBasicDemographics', | ||
// 'Donufriienko:PredictSEXByAGEHEIGHTWEIGHTUsingDistributedRandomForest', | ||
// data, | ||
// {'SEX': 'SEX', 'AGE': 'AGE', 'HEIGHT': 'HEIGHT', 'WEIGHT': 'WEIGHT'}, | ||
// true, | ||
// ); | ||
// expect((resultDf.columns as DG.ColumnList).names().includes('outcome'), true); | ||
// }); | ||
test('Cluster', async () => { | ||
@@ -28,13 +15,2 @@ const data = await _package.files.readCsv('datasets/xclara.csv'); | ||
test('Missing Values Imputation', async () => { | ||
const data = await _package.files.readCsv('datasets/demog.csv'); | ||
const resultDf = await grok.ml.missingValuesImputation( | ||
data, ['age', 'height', 'weight'], ['age', 'height', 'weight'], 5, | ||
); | ||
expect(resultDf.getCol('age').isNone(1192), false); | ||
expect(resultDf.getCol('height').isNone(2220), false); | ||
expect(resultDf.getCol('weight').isNone(2221), false); | ||
}); | ||
test('PCA', async () => { | ||
@@ -49,22 +25,2 @@ const data = await _package.files.readCsv('datasets/cars.csv'); | ||
}); | ||
test('Random Data', async () => { | ||
const seed = 42; | ||
const data = await _package.files.readCsv('datasets/demog.csv'); | ||
await grok.ml.randomData(data, 'normal', {sd: 3.0, mean: 1.0}, seed); | ||
await grok.ml.randomData(data, 'uniform', {min: 0.0, max: 1.0}, seed); | ||
await grok.ml.randomData(data, 'binomial', {size: 100, prob: 0.7}, seed); | ||
//too naive? | ||
const normalCol = data.getCol('normal'); | ||
expect(0.9 <= normalCol.stats.avg && normalCol.stats.avg <= 1.1, true); | ||
expect(2.9 <= normalCol.stats.stdev && normalCol.stats.stdev <= 3.1, true); | ||
const uniformCol = data.getCol('uniform'); | ||
expect(uniformCol.stats.min >= 0.0 && uniformCol.stats.max <= 1.0, true); | ||
const binomialCol = data.getCol('binomial'); | ||
expect(binomialCol.stats.min >= 0 && binomialCol.stats.max <= 100, true); | ||
expect(68 <= binomialCol.stats.avg && binomialCol.stats.avg <= 72, true); | ||
}); | ||
}); | ||
@@ -18,11 +18,11 @@ import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
test('Dev Settings', async () => { | ||
expect(gss.loadDefaultsOnStart, true); | ||
expect(gss.webpackDevUrl, null); | ||
expect(gss.cvmUrl.startsWith('https://cvm'), true); | ||
expect(gss.cvmSplit, true); | ||
expect(gss.apiUrl.endsWith('/api'), true); | ||
expect(gss.helpBaseUrl, ''); | ||
expect(gss.jupyterNotebook, `${gss.cvmUrl}/notebook`); | ||
expect(typeof gss.jupyterGatewayToken, 'string'); | ||
expect(typeof gss.jupyterNotebookToken, 'string'); | ||
expect(gss.loadDefaultsOnStart, true, 'loadDefaultsOnStart'); | ||
expect(gss.webpackDevUrl, null, 'webpackDevUrl'); | ||
expect(gss.cvmUrl.startsWith('https://cvm'), true, 'cvmUrl'); | ||
expect(gss.cvmSplit, true, 'cvmSplit'); | ||
expect(gss.apiUrl.endsWith('/api'), true, 'apiUrl'); | ||
expect(gss.helpBaseUrl, '', 'helpBaseUrl'); | ||
expect(gss.jupyterNotebook, `${gss.cvmUrl}/notebook`, 'jupyterNotebook'); | ||
expect(typeof gss.jupyterGatewayToken, 'string', 'jupyterGatewayToken'); | ||
expect(typeof gss.jupyterNotebookToken, 'string', 'jupyterNotebookToken'); | ||
}); | ||
@@ -64,20 +64,11 @@ | ||
test('Windows Settings', async () => { | ||
expect(gss.showMenu, !grok.shell.windows.simpleMode, | ||
`showMenu ${gss.showMenu} != ${!grok.shell.windows.simpleMode}`); | ||
expect(gss.showTables, grok.shell.windows.showTables, | ||
`showTables ${gss.showTables} != ${!grok.shell.windows.showTables}`); | ||
expect(gss.showColumns, grok.shell.windows.showColumns, | ||
`showColumns ${gss.showColumns} != ${!grok.shell.windows.showColumns}`); | ||
expect(gss.showProperties, grok.shell.windows.showProperties, | ||
`showProperties ${gss.showProperties} != ${!grok.shell.windows.showProperties}`); | ||
expect(gss.showToolbox, grok.shell.windows.showToolbox, | ||
`showToolbox ${gss.showToolbox} != ${!grok.shell.windows.showToolbox}`); | ||
expect(gss.showStatusBar, grok.shell.windows.showStatusBar, | ||
`showStatusBar ${gss.showStatusBar} != ${!grok.shell.windows.showStatusBar}`); | ||
expect(gss.showVariables, grok.shell.windows.showVariables, | ||
`showVariables ${gss.showVariables} != ${!grok.shell.windows.showVariables}`); | ||
expect(gss.showConsole, grok.shell.windows.showConsole, | ||
`showConsole ${gss.showConsole} != ${!grok.shell.windows.showConsole}`); | ||
expect(gss.showHelp, grok.shell.windows.showHelp, | ||
`showHelp ${gss.showHelp} != ${!grok.shell.windows.showHelp}`); | ||
expect(gss.showMenu, !grok.shell.windows.simpleMode, 'showMenu'); | ||
expect(gss.showTables, grok.shell.windows.showTables, 'showTables'); | ||
expect(gss.showColumns, grok.shell.windows.showColumns, 'showColumns'); | ||
expect(gss.showProperties, grok.shell.windows.showProperties, 'showProperties'); | ||
expect(gss.showToolbox, grok.shell.windows.showToolbox, 'showToolbox'); | ||
expect(gss.showStatusBar, grok.shell.windows.showStatusBar, 'showStatusBar'); | ||
expect(gss.showVariables, grok.shell.windows.showVariables, 'showVariables'); | ||
expect(gss.showConsole, grok.shell.windows.showConsole, 'showConsole'); | ||
expect(gss.showHelp, grok.shell.windows.showHelp, 'showHelp'); | ||
}); | ||
@@ -84,0 +75,0 @@ |
@@ -5,3 +5,3 @@ import * as grok from 'datagrok-api/grok'; | ||
import $ from 'cash-dom'; | ||
import {before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {before, category, expect, test, awaitCheck} from '@datagrok-libraries/utils/src/test'; | ||
@@ -12,3 +12,2 @@ | ||
let packageDataConnection: DG.DataConnection; | ||
const timeout = 2500; | ||
const labelSelector = '.d4-tree-view-tri.d4-tree-view-tri-expanded + i + .d4-tree-view-group-label'; | ||
@@ -23,14 +22,16 @@ | ||
const fw = DG.FilesWidget.create(); | ||
expect(fw instanceof DG.FilesWidget, true); | ||
expect(fw.root instanceof HTMLElement, true); | ||
expect(fw.root.classList.contains('d4-tree-view-root'), true); | ||
expect(ui.fileBrowser() instanceof DG.FilesWidget, true) | ||
expect(fw instanceof DG.FilesWidget, true, 'fw'); | ||
expect(fw.root instanceof HTMLElement, true, 'fw.root'); | ||
expect(fw.root.classList.contains('d4-tree-view-root'), true, 'fw.root.classList'); | ||
expect(ui.fileBrowser() instanceof DG.FilesWidget, true, 'fw.fileBrowser()'); | ||
if (testConnection) { | ||
const testFW = ui.fileBrowser({path: testConnection.nqName}); | ||
setTimeout(() => { | ||
awaitCheck(() => { | ||
if (testFW.root.querySelector('.grok-loader')) return false; | ||
const label = $(testFW.root).find(labelSelector)[0]; | ||
expect(label != null, true); | ||
expect(label!.textContent, testConnection.friendlyName); | ||
}, timeout); | ||
expect(label != null, true, 'label'); | ||
expect(label!.textContent, testConnection.friendlyName, 'label!.textContent'); | ||
return true; | ||
}, 'Home timeout', 10000); | ||
} | ||
@@ -42,13 +43,13 @@ | ||
const testFW = ui.fileBrowser({path: `${packageDataConnection.nqName}/${packageName}/${packageDir}`}); | ||
setTimeout(() => { | ||
awaitCheck(() => { | ||
if (testFW.root.querySelector('.grok-loader')) return false; | ||
const labels = $(testFW.root).find(labelSelector); | ||
expect(labels[0] != null, true); | ||
expect(labels[0]!.textContent, packageDataConnection.friendlyName); | ||
expect(labels[1] != null, true); | ||
expect(labels[1]!.textContent, packageName); | ||
expect(labels[2] != null, true); | ||
expect(labels[2]!.textContent, packageDir); | ||
}, timeout); | ||
expect(labels[0] != null, true, 'labels[0]'); | ||
expect(labels[0]!.textContent, packageDataConnection.friendlyName, 'labels[0]!.textContent'); | ||
expect(labels[1] != null, true, 'labels[1]'); | ||
expect(labels[1]!.textContent, packageName, 'labels[1]!.textContent'); | ||
return true; | ||
}, 'AppData timeout', 10000); | ||
} | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1306416
78
3454
8