123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /**
- * Created by Tony on 2017/8/4.
- */
- let test = require('tape');
- let mongoose = require("mongoose");
- let dbm = require("../../../config/db/db_manager");
- require('../../../modules/main/models/prj_properties');
- let ppFacade = require('../../../modules/main/facade/prj_properties_facade');
- //let randomPrjId = Math.round(Math.random() * 100);
- let randomPrjId = 35;
- dbm.connect();
- // test('测试 - 创建dummy项目属性: ', function (t) {
- // let items = [];
- // items.push({key: "contractNum", dispName: "合同号", value: "天字第一号"});
- // items.push({key: "appType", dispName: "工程专业", value: "建筑工程"});
- // items.push({key: "constructType", dispName: "工程类别", value: "住宅"});
- // items.push({key: "startDate", dispName: "建设日期", value: "2017-07-31"});
- // items.push({key: "owner", dispName: "建设单位", value: "珠海纵横创新"});
- // items.push({key: "designer", dispName: "设计单位", value: "珠海设计局"});
- // items.push({key: "builder", dispName: "施工单位", value: "中建十局"});
- //
- // let results = ppFacade.createPrjProperties(randomPrjId, items);
- // results.then(function(rst) {
- // console.log('rst.projectID: ' + rst.projectID);
- // for (let prop of rst.properties) {
- // console.log('property ' + prop.dispName + ': ' + prop.value);
- // }
- // t.pass('just pass!');
- // t.end();
- // });
- // });
- // test('测试 - 整个更新项目属性: ', function (t) {
- // let items = [];
- // items.push({key: "contractNum", dispName: "合同号", value: "人字第三号"});
- // items.push({key: "appType", dispName: "工程专业", value: "建筑工程"});
- // items.push({key: "constructType", dispName: "工程类别", value: "住宅"});
- // items.push({key: "startDate", dispName: "建设日期", value: "2017-08-01"});
- // items.push({key: "owner", dispName: "建设单位", value: "珠海纵横创新"});
- // items.push({key: "designer", dispName: "设计单位", value: "珠海设计局"});
- // items.push({key: "builder", dispName: "施工单位", value: "中建十局"});
- //
- // let udtObj = {"projectID": 35, "properties": items};
- //
- // let rst = ppFacade.updateWhole(udtObj);
- // if (rst) {
- // rst.then(function(results){
- // for (let prop in results) {
- // console.log(prop + ': ' + results[prop]);
- // }
- // t.pass('just pass!');
- // t.end();
- // });
- // } else {
- // console.log('update failed!');
- // t.pass('just pass!');
- // t.end();
- // }
- // });
- // test('测试 - 新增项目属性: ', function (t) {
- // let newItem = {key: "auditor", dispName: "监理单位", value: "珠海德信"};
- // let results = ppFacade.addOrChangeProperty(35, newItem);
- // if (results instanceof Promise) {
- // results.then(function (rst) {
- // for (let prop in rst) {
- // console.log("property " + prop + ' : ' + rst[prop]);
- // }
- // })
- // } else {
- // for (let prop in results) {
- // console.log("property " + prop + ' : ' + results[prop]);
- // }
- // }
- //
- // t.pass('just pass!');
- // t.end();
- //
- // });
- // test('测试 - 删除全体项目属性: ', function (t) {
- // let rst = ppFacade.removeProperty(35);
- // if (rst) {
- // if (rst instanceof Promise) {
- // rst.then(function(results){
- // for (let prop in results) {
- // console.log(prop + ': ' + results[prop]);
- // }
- // t.pass('just pass with remove1!');
- // t.end();
- // });
- // } else {
- // for (let prop in results) {
- // console.log(prop + ': ' + results[prop]);
- // }
- // t.pass('just pass with remove2!');
- // t.end();
- // }
- // } else {
- // t.pass('just pass but not remove!');
- // t.end();
- // }
- // });
- // test('测试 - 更新项目属性: ', function (t) {
- // let rst = ppFacade.updateOneProperty(35, "builder", "中建十一局");
- // if (rst) {
- // rst.then(function(results){
- // for (let prop in results) {
- // console.log(prop + ': ' + results[prop]);
- // }
- // t.pass('just pass with update!');
- // t.end();
- // });
- // } else {
- // t.pass('just pass but not update!');
- // t.end();
- // }
- // });
- // test('测试 - 移除一项属性: ', function (t) {
- // let rst = ppFacade.removeOneProperty(35, "auditor");
- // if (rst) {
- // rst.then(function(results){
- // for (let prop in results) {
- // console.log(prop + ': ' + results[prop]);
- // }
- // t.pass('just pass with remove!');
- // t.end();
- // });
- // } else {
- // t.pass('just pass but not remove!');
- // t.end();
- // }
- // });
- test('close the connection', function (t) {
- setTimeout(function () {
- mongoose.disconnect();
- t.pass('closing db connection');
- t.end();
- }, 1500);
- })
|