Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Sounds good for you? Then let's get started!
- [Node.js](https://nodejs.org/) >= 14
- [npm](https://npmjs.com/) >= 5
- [Python](https://www.python.org/downloads/) >= 3
- [Pipenv](https://docs.pipenv.org)
- [Pipenv](https://docs.pipenv.org) >= 2020.11.15
- Supported OSes: Linux, macOS and Windows

To install these prerequisites, you can follow the [How To section](https://docs.getleon.ai/how-to/) of the documentation.
Expand Down
1 change: 0 additions & 1 deletion bridges/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
queryobjectpath = argv[1]
codes = []

serversrc = 'dist' if environ.get('LEON_NODE_ENV') == 'production' else 'src'
queryobjfile = open(queryobjectpath, 'r', encoding = 'utf8')
queryobj = loads(queryobjfile.read())
queryobjfile.close()
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
"scripts": {
"lint": "babel-node scripts/lint.js",
"test": "npm run test:json && npm run test:unit && npm run test:e2e",
"test:unit": "npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --forceExit --silent --projects test/unit/unit.jest.json && npm run train expressions",
"test:unit": "npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --forceExit --silent --projects test/unit/unit.jest.json && npm run train expressions",
"test:e2e": "npm run test:e2e:nlp-modules && npm run test:e2e:modules",
"test:e2e:modules": "npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --forceExit --silent --verbose --projects test/e2e/modules/e2e.modules.jest.json && npm run train expressions",
"test:e2e:nlp-modules": "npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --forceExit --silent --verbose --setupTestFrameworkScriptFile=./test/paths.setup.js test/e2e/nlp-modules.spec.js && npm run train expressions",
"test:e2e:modules": "babel-node scripts/run-clean-test-dbs.js && npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --forceExit --silent --verbose --projects test/e2e/modules/e2e.modules.jest.json && babel-node scripts/run-clean-test-dbs.js && npm run train expressions",
"test:e2e:nlp-modules": "npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --forceExit --silent --verbose --setupTestFrameworkScriptFile=./test/paths.setup.js test/e2e/nlp-modules.spec.js && npm run train expressions",
"test:json": "jest --silent --projects test/json/json.jest.json",
"test:module": "babel-node scripts/test-module.js",
"setup:offline": "babel-node scripts/setup-offline/setup-offline.js",
Expand Down
13 changes: 0 additions & 13 deletions packages/calendar/test/todolist.spec.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import path from 'path'
import fs from 'fs'

describe('calendar:todolist', async () => {
// Once the tests are done, delete test DB file if it exists
afterAll(() => {
const pkgName = 'calendar'
const dbFile = path.join(__dirname, `../data/db/${pkgName}.spec.json`)

if (fs.existsSync(dbFile)) {
fs.unlinkSync(dbFile)
}
})

test('no list', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Show all my lists')
Expand Down
2 changes: 1 addition & 1 deletion packages/calendar/todolist.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,4 @@ def dbCreateTodo(listname, todoname):
'is_completed': False,
'created_at': timestamp,
'updated_at': timestamp
})
})
34 changes: 34 additions & 0 deletions scripts/clean-test-dbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fs from 'fs'
import { join } from 'path'

import log from '@/helpers/log'

/**
* This script delete test DB files if they exist
*/
export default () => new Promise(async (resolve, reject) => {
log.info('Cleaning test DB files...')

const packagesFolder = join(__dirname, '../packages')
const packages = fs.readdirSync(packagesFolder)
.filter((entity) => fs.statSync(join(packagesFolder, entity)).isDirectory())

for (let i = 0; i < packages.length; i += 1) {
try {
const dbFolder = join(packagesFolder, packages[i], 'data/db')
const dbTestFiles = fs.readdirSync(dbFolder).filter((entity) => entity.indexOf('.spec.json') !== -1)

if (dbTestFiles.length > 0) {
log.info(`Deleting ${dbTestFiles[0]}...`)
fs.unlinkSync(join(dbFolder, dbTestFiles[0]))
log.success(`${dbTestFiles[0]} deleted`)
}
} catch (e) {
log.error(`Failed to clean: ${packages[i]} test DB file`)
reject(e)
}
}

log.success('Cleaning done')
resolve()
})
14 changes: 14 additions & 0 deletions scripts/run-clean-test-dbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import log from '@/helpers/log'

import cleanTestDbs from './clean-test-dbs'

/**
* Execute the cleaning test DBs script
*/
(async () => {
try {
await cleanTestDbs()
} catch (e) {
log.error(`Failed to clean test DBs: ${e}`)
}
})()
1 change: 0 additions & 1 deletion test/e2e/modules/e2e.modules.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ global.date = {
}

process.env.LEON_LANG = 'en-US'
process.env.LEON_NODE_ENV = 'testing'
process.env.LEON_TIME_ZONE = global.date.time_zone

beforeAll(async () => {
Expand Down
1 change: 0 additions & 1 deletion test/unit/unit.setup.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.