Loading...
Searching...
No Matches
getrawdata.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing getrawdata service
4
5 <h4> SAS Macros </h4>
6 @li mp_assertdsobs.sas
7 @li mp_assert.sas
8 @li mx_execute.sas
9
10**/
11
12
13%let _program=&appLoc/services/public/getrawdata;
14
15/* test1 - regular table */
16data work.params;
17 length name $32 value $1000;
18 name='type';value='CSV';output;
19 name='table';value="&dclib..MPE_X_TEST";output;
20 name='filter';value='0';output;
21run;
22
23%mx_execute(&_program,
24 viyacontext=&defaultcontext,
25 inputparams=work.params,
26 outref=webout,
27 viyaresult=WEBOUT_TXT,
28 mdebug=&sasjs_mdebug
29)
30
31data work.results;
32 infile webout;
33 input;
34 if _infile_=:'PRIMARY_KEY_FIELD, SOME_CHAR' then do;
35 output;
36 output;
37 stop;
38 end;
39 else if _n_<5 then putlog _infile_;
40run;
41
42%mp_assertdsobs(work.results,
43 desc=CSV file is successfully returned,
44 test=EQUALS 2,
45 outds=work.test_results
46)
47
48/* test 2 - format table */
49data work.params2;
50 length name $32 value $1000;
51 name='type';value='SAS';output;
52 name='table';value="DCTEST.DCFMTS-FC";output;
53 name='filter';value='0';output;
54run;
55
56%mx_execute(&_program,
57 viyacontext=&defaultcontext,
58 inputparams=work.params2,
59 outref=web2,
60 viyaresult=WEBOUT_TXT
61)
62
63data work.results2;
64 infile web2;
65 input;
66 putlog _infile_;
67 if _infile_=:'datalines4;' then do;
68 output;
69 output;
70 output;
71 stop;
72 end;
73 if _n_>100 then stop;
74run;
75
76%mp_assertdsobs(work.results2,
77 desc=datalines file is successfully returned for format catalog,
78 test=EQUALS 3,
79 outds=work.test_results
80)
81
82/* test 3 - when there is a format catalog / nothing else in the library */
83data work.params3;
84 length name $32 value $1000;
85 name='type';value='SAS';output;
86 name='table';value="FMTONLY.DCFMTS-FC";output;
87 name='filter';value='0';output;
88run;
89
90%mx_execute(&_program,
91 viyacontext=&defaultcontext,
92 inputparams=work.params3,
93 outref=web3,
94 viyaresult=WEBOUT_TXT
95)
96
97data work.results3;
98 infile web3;
99 input;
100 putlog _infile_;
101 if _infile_=:'datalines4;' then do;
102 output;
103 output;
104 output;
105 stop;
106 end;
107 if _n_>100 then stop;
108run;
109
110%mp_assertdsobs(work.results3,
111 desc=datalines file is successfully returned for LONE format catalog,
112 test=EQUALS 3,
113 outds=work.test_results
114)
115
116/* test 4 - PDF report */
117data work.params4;
118 length name $32 value $1000;
119 name='type';value='PDF';output;
120 name='table';value="&dclib..MPE_X_TEST";output;
121 name='filter';value='0';output;
122run;
123
124%mx_execute(&_program,
125 viyacontext=&defaultcontext,
126 inputparams=work.params4,
127 outref=webpdf,
128 viyaresult=WEBOUT_TXT
129)
130
131/* the PDF is binary, so it is read as raw bytes rather than as lines the way
132 the text formats are. The magic number is built with byte(37) so that the
133 percent sign is not read as a macro call. */
134data _null_;
135 infile webpdf recfm=f lrecl=8 obs=1;
136 length sig $8 pdfpfx $5;
137 input sig $8.;
138 pdfpfx=cat(byte(37),'PDF-');
139 call symputx('is_pdf',ifn(substr(sig,1,5)=pdfpfx,1,0),'l');
140run;
141
142%mp_assert(
143 iftrue=(&is_pdf=1),
144 desc=PDF report is returned with a PDF signature,
145 outds=work.test_results
146)