12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- const { app, assert } = require('egg-mock/bootstrap');
- const mockData = {};
- const path = require('path');
- const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
- describe('test/app/service/report_memory.test.js', () => {
- // 准备测试数据
- before(function* () {
- const ctx = app.mockContext();
- // 模拟登录session
- // const postData = {
- // account: '734406061@qq.com',
- // project: 'T201711273363',
- // project_password: 'mai654321',
- // };
- const postData = {
- account: 'fuqingqing',
- project: 'P0505',
- project_password: '123456',
- };
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
- assert(loginResult);
- mockData.session = ctx.session;
- });
- // 数据
- it('test getReportData', function* () {
- const ctx = app.mockContext(mockData);
- // test12 - 第6期
- //const stage = yield ctx.service.stage.getDataByCondition({tid: 2076, order: 2});
- const params = {
- tender_id: 1977
- };
- const filters = ['change', 'mem_change_bills'];
- const fields = {
- change: [],
- mem_stage_bills: [],
- };
- const result = yield ctx.service.report.getReportData(params, filters, fields);
- reportDataAnalysis.analysisObj.changeSort.fun(ctx, result, [], {change: "change", changeBills: 'mem_change_bills'});
- const savePath = path.join(ctx.app.baseDir, 'report_temp');
- yield ctx.helper.recursiveMkdirSync(savePath);
- for (const table in result) {
- yield ctx.helper.saveBufferFile(JSON.stringify(result[table],"","\t"), path.join(savePath, table + '.json'));
- }
- });
- });
|