|  | @@ -0,0 +1,53 @@
 | 
	
		
			
				|  |  | +'use strict';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * @author Mai
 | 
	
		
			
				|  |  | + * @date
 | 
	
		
			
				|  |  | + * @version
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +const { app, assert } = require('egg-mock/bootstrap');
 | 
	
		
			
				|  |  | +const mockData = {};
 | 
	
		
			
				|  |  | +const path = require('path');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +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 getReportData', function* () {
 | 
	
		
			
				|  |  | +        const ctx = app.mockContext(mockData);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // test12 - 第6期
 | 
	
		
			
				|  |  | +        const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});
 | 
	
		
			
				|  |  | +        const params = {
 | 
	
		
			
				|  |  | +            tender_id: stage.tid,
 | 
	
		
			
				|  |  | +            stage_id: stage.id,
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        const filters = ['change', 'change_audit_list'];
 | 
	
		
			
				|  |  | +        const result = yield ctx.service.report.getReportData(ctx, params, filters);
 | 
	
		
			
				|  |  | +        const savePath = path.join(ctx.app.baseDir, 'report_temp');
 | 
	
		
			
				|  |  | +        yield ctx.helper.recursiveMkdirSync(savePath);
 | 
	
		
			
				|  |  | +        for (const table in result) {
 | 
	
		
			
				|  |  | +            yield ctx.helper.saveBufferFile(JSON.stringify(result[table],"","\t"), path.join(savePath, table + '.json'));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +});
 |