rpt_tpl_tree_test.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * Created by Tony on 2017/9/15.
  3. */
  4. const test = require("tape");
  5. const mongoose = require("mongoose");
  6. let config = require("../../../config/config.js");
  7. //config.setupDb(process.env.NODE_ENV);
  8. config.setupDb('qa');
  9. const dbm = require("../../../config/db/db_manager");
  10. const rttFacade = require("../../../modules/reports/facade/rpt_tpl_tree_node_facade");
  11. dbm.connect();
  12. /*
  13. test('测试 - 创建dummy报表树: ', function (t) {
  14. let tprTplTree = {};
  15. tprTplTree.compilationId = "598d239605cdd825682925d1";
  16. tprTplTree.engineerId = 1;
  17. tprTplTree.userId = -100;
  18. tprTplTree.properties = [{"isZhaoBiao": false}, {"isBills": true}];
  19. tprTplTree.name = "重庆市建筑工程";
  20. tprTplTree.released = true;
  21. tprTplTree.isDeleted = false;
  22. tprTplTree.items = [];
  23. tprTplTree.items.push( {nodeType: 1, refId: -1, name: "【封-1】招标工程量清单", items: null} );
  24. tprTplTree.items.push( {nodeType: 1, refId: -1, name: "【表-09】分部分项工程/施工技术措施项目清单计价表", items: null} );
  25. let results = rttFacade.createNewTree(tprTplTree);
  26. results.then(function(rst) {
  27. console.log(rst);
  28. t.pass('just pass!');
  29. t.end();
  30. });
  31. });
  32. //*/
  33. /*
  34. test('测试 - 创建dummy报表树2: ', function (t) {
  35. let tprTplTree = {};
  36. tprTplTree.compilationId = "598d239605cdd825682925d1";
  37. tprTplTree.engineerId = 2;
  38. tprTplTree.userId = -100;
  39. tprTplTree.properties = [{"isZhaoBiao": false}, {"isBills": true}];
  40. tprTplTree.name = "重庆市装饰工程";
  41. tprTplTree.released = true;
  42. tprTplTree.isDeleted = false;
  43. tprTplTree.items = [];
  44. tprTplTree.items.push( {nodeType: 1, refId: -1, name: "【封-1】招标工程量清单", items: null} );
  45. tprTplTree.items.push( {nodeType: 1, refId: -1, name: "【表-09】分部分项工程/施工技术措施项目清单计价表", items: null} );
  46. let results = rttFacade.createNewTree(tprTplTree);
  47. results.then(function(rst) {
  48. console.log(rst);
  49. t.pass('just pass!');
  50. t.end();
  51. });
  52. });
  53. //*/
  54. /*
  55. test('测试 - 更新 dummy报表树2: ', function (t) {
  56. let tprTplTree = {};
  57. tprTplTree.compilationId = "598d239605cdd825682925d1";
  58. tprTplTree.engineerId = 2;
  59. tprTplTree.userId = -100;
  60. tprTplTree.properties = [{"isZhaoBiao": false}, {"isBills": true}];
  61. tprTplTree.name = "重庆市装饰工程";
  62. tprTplTree.released = false;
  63. tprTplTree.isDeleted = false;
  64. tprTplTree.items = [];
  65. tprTplTree.items.push( {nodeType: 1, refId: -1, name: "【封-1】招标工程量清单", items: null} );
  66. tprTplTree.items.push( {nodeType: 1, refId: -1, name: "【表-09】分部分项工程/施工技术措施项目清单计价表", items: null} );
  67. tprTplTree.items.push( {nodeType: 1, refId: -1, name: "【表-09-1】分部分项工程/施工技术措施项目清单计价表(一)", items: null} );
  68. let results = rttFacade.updateTree(tprTplTree.compilationId, tprTplTree.engineerId, tprTplTree.userId, tprTplTree);
  69. results.then(function(rst) {
  70. console.log(rst);
  71. t.pass('just pass!');
  72. t.end();
  73. });
  74. });
  75. //*/
  76. /*
  77. test('测试 - 真正删除 dummy报表树2: ', function (t) {
  78. let results = rttFacade.removeTreePhycically("598d239605cdd825682925d1", 2, -100);
  79. results.then(function(rst) {
  80. console.log(rst);
  81. t.pass('just pass!');
  82. t.end();
  83. });
  84. });
  85. //*/
  86. /*
  87. test('测试 - 删除 dummy 报表树: ', function (t) {
  88. let results = rttFacade.removeTree("598d239605cdd825682925d1", 2, -100, function(err, rst){
  89. console.log(err);
  90. console.log(rst);
  91. });
  92. results.then(function(err, rst) {
  93. //mongoose.disconnect();
  94. t.pass('just pass!');
  95. t.end();
  96. });
  97. });
  98. //*/
  99. /*
  100. test('测试 - find dummy 报表树 by ObjectId: ', function (t) {
  101. let results = rttFacade.findTplTreeByOid("59bb7fbbbe61c629c0b2bea6");
  102. results.then(function(rst) {
  103. console.log(rst);
  104. //mongoose.disconnect();
  105. t.pass('just pass!');
  106. t.end();
  107. });
  108. });
  109. //*/
  110. //*
  111. test('测试 - find dummy 报表树 ', function (t) {
  112. let results = rttFacade.findTplTree("598d239605cdd825682925d1", [1], [-101]);
  113. results.then(function(rst) {
  114. if (rst) {
  115. console.log('no result');
  116. } else {
  117. console.log(rst);
  118. }
  119. //mongoose.disconnect();
  120. t.pass('just pass!');
  121. t.end();
  122. });
  123. });
  124. //*/
  125. //*
  126. test('close the connection', function (t) {
  127. setTimeout(function () {
  128. mongoose.disconnect();
  129. t.pass('closing db connection');
  130. t.end();
  131. }, 500);
  132. // mongoose.disconnect();
  133. // t.pass('closing db connection');
  134. // t.end();
  135. });
  136. //*/