1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date
- * @version
- */
- const { app, assert } = require('egg-mock/bootstrap');
- const mockData = {};
- 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: 'chente',
- // project: 'T201711273363',
- // project_password: '123456',
- // };
- ctx.session = {};
- const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
- assert(loginResult);
- mockData.session = ctx.session;
- });
- // 生成中间计量表数据 - 台账
- it('test getStageImTzData & getStageImTzBillsData', function* () {
- const ctx = app.mockContext(mockData);
- // test12 - 第6期
- const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
- const mainData = yield ctx.service.reportMemory.getStageImTzData(12, stage.id);
- const billsData = yield ctx.service.reportMemory.getStageImTzBillsData(12, stage.id);
- if (mainData instanceof Array) {
- console.log('mem_stage_im_tz.length:' + mainData.length);
- yield ctx.helper.saveBufferFile(JSON.stringify(mainData,"","\t"), ctx.app.baseDir + '/mem_stage_im_tz.json');
- }
- if (billsData instanceof Array) {
- console.log('mem_stage_im_tz_bills.length:' + billsData.length);
- yield ctx.helper.saveBufferFile(JSON.stringify(billsData,"","\t"), ctx.app.baseDir + '/mem_stage_im_tz_bills.json');
- }
- });
- // 生成中间计量表数据 - 总量
- it('test getStageImZlData', function* () {
- const ctx = app.mockContext(mockData);
- // test12 - 第6期
- const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
- const mainData = yield ctx.service.reportMemory.getStageImZlData(12, stage.id);
- if (mainData instanceof Array) {
- yield ctx.helper.saveBufferFile(JSON.stringify(mainData,"","\t"), ctx.app.baseDir + '/mem_stage_im_zl.json');
- }
- });
- });
|