report_memory.test.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const mockData = {};
  11. describe('test/app/service/report_memory.test.js', () => {
  12. // 准备测试数据
  13. before(function* () {
  14. const ctx = app.mockContext();
  15. // 模拟登录session
  16. const postData = {
  17. account: '734406061@qq.com',
  18. project: 'T201711273363',
  19. project_password: 'mai654321',
  20. };
  21. ctx.session = {};
  22. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  23. assert(loginResult);
  24. mockData.session = ctx.session;
  25. });
  26. // 生成中间计量表数据 - 台账
  27. it('test getStageImTzData & getStageImTzBillsData', function* () {
  28. const ctx = app.mockContext(mockData);
  29. // test12 - 第6期
  30. const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
  31. const mainData = yield ctx.service.reportMemory.getStageImTzData(12, stage.id);
  32. const billsData = yield ctx.service.reportMemory.getStageImTzBillsData(12, stage.id);
  33. if (mainData instanceof Array) {
  34. yield ctx.helper.saveBufferFile(JSON.stringify(mainData,"","\t"), ctx.app.baseDir + '/mem_stage_im_tz.json');
  35. }
  36. if (billsData instanceof Array) {
  37. yield ctx.helper.saveBufferFile(JSON.stringify(billsData,"","\t"), ctx.app.baseDir + '/mem_stage_im_tz_bills.json');
  38. }
  39. });
  40. // 生成中间计量表数据 - 总量
  41. it('test getStageImZlData', function* () {
  42. const ctx = app.mockContext(mockData);
  43. // test12 - 第6期
  44. const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
  45. const mainData = yield ctx.service.reportMemory.getStageImZlData(12, stage.id);
  46. if (mainData instanceof Array) {
  47. yield ctx.helper.saveBufferFile(JSON.stringify(mainData,"","\t"), ctx.app.baseDir + '/mem_stage_im_zl.json');
  48. }
  49. });
  50. });