def test_testName(self): color.blue("test here baby") fileContent = """commentCollection = require '../commentCollection.iced' th = require 'throw' module.exports = (db, text, orgId, cb)-> collection = commentCollection db await collection.ensureIndex {Info: text}, defer() await collection.find({Info: text, OrgId: orgId}).sort({DateCreate: -1}).toArray defer err, comments cb null, comments""" result = returnLast.getReturnParamsForAutocbCommaSeparated(fileContent) expected = "err, comments" assertMy.equals(result, expected)
def do(targeFilename, sourceFilename): target = targeFilename source = sourceFilename print("target:", target, "-----------------------------------------------------") print("source:", source, "-----------------------------------------------------") rel = absRel.RelAndCutIfNodeModules(source, target) # 1) get fileName by filePath filename = absRel.filename(target) # 2) create string: #{fileName} = require '#{relativePath}' require = "{0} = require '{1}'".format(filename, rel) # 3) set to cliboard objectName - filename # 3.1) get param names: # get fileContent_target to load it once: fileContent_target = filer2.read(target) # check if function sync: sync = callForSyncFunc.isItSync(fileContent_target) color.red("sync in relativeRequireIced_model.py") print(sync) isCbWithouAutocb = callForSyncFunc.isItCb(fileContent_target) color.red("isCbWithouAutocb in relativeRequireIced_model.py") print(isCbWithouAutocb) if isCbWithouAutocb: # (...,cb)-> params = getParams.getParamsCb(fileContent_target) ending = returnLast.getReturnParamsForAutocbCommaSeparated(fileContent_target) toClip = "await {0}{1} defer {2}".format(filename, params, ending) else: if sync: # load params sync params = callForSyncFunc.byFileContent(fileContent_target) returnParams = returnLast.returnParamsForSyncExpressionOrReturn(fileContent_target) toClip = "{2} = {0}{1}".format(filename, params, returnParams) else: # async: (..., autocb)-> params = getParams.getParamsAutocb(fileContent_target) autocbOneEnding = returnLast.autocbOneEnding(fileContent_target) if autocbOneEnding: toClip = "await {0}{1} defer {2}".format(filename, params, autocbOneEnding) else: ending = returnLast.doAllByFileName(target) toClip = "await {0}{1} defer result{2}".format(filename, params, ending) result = (require, toClip) return result
def test_testName(self): color.blue("test here baby") fileContent = """th = require 'throw' mdb_shir_cb = require '../mdb_shir_cb.iced' cityCollection = require './cityCollection.iced' module.exports = (db, cb)-> await mdb_shir_cb defer err, db collection = cityCollection db query = longLat: {$exists: true} await collection.find(query).toArray defer err, cityListWithLongLat th.err err cb cityListWithLongLat """ result = returnLast.getReturnParamsForAutocbCommaSeparated(fileContent) expected = "cityListWithLongLat" assertMy.equals(result, expected)