123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- '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');
- }
- });
- // 月进度数据
- it('test getMonthProgress', function* () {
- const ctx = app.mockContext(mockData);
- // test12
- const mainData = yield ctx.service.reportMemory.getMonthProgress(12);
- if (mainData instanceof Array) {
- yield ctx.helper.saveBufferFile(JSON.stringify(mainData,"","\t"), ctx.app.baseDir + '/mem_month_progress.json');
- }
- });
- });
|