Loading...
Searching...
No Matches
getstagetable.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing getstagetable service
4
5 <h4> SAS Macros </h4>
6 @li mx_execute.sas
7 @li mp_assert.sas
8
9 @sasjslint {"maxLineLength": 81}
10
11**/
12
13/**
14 * First part - stage some data (to fetch via getstagetable)
15 */
16data work.sascontroltable;
17 action='LOAD';
18 message="getstagetable prep";
19 libds="&dclib..MPE_X_TEST";
20 output;
21 stop;
22run;
23
24proc sql noprint;
25select max(primary_key_field) into: maxpk
26 from &dclib..mpe_x_test;
27
28data work.jsdata;
29 set &dclib..mpe_x_test(rename=(
30 some_date=dt2 SOME_DATETIME=dttm2 SOME_TIME=tm2)
31 );
32 /* the adapter sends these as strings - see postdata.test.1 */
33 some_date=put(dt2,date9.);
34 SOME_DATETIME=put(dttm2,datetime19.);
35 some_time=put(tm2,time.);
36 drop dt2 dttm2 tm2;
37 if _n_=1 then do;
38 _____DELETE__THIS__RECORD_____='No';
39 some_char='getstagetable test';
40 some_num=&maxpk+1;
41 output;
42 end;
43 else stop;
44run;
45
46%mx_execute(&appLoc/services/editors/stagedata,
47 viyacontext=&defaultcontext,
48 inputdatasets=work.sascontroltable work.jsdata,
49 outlib=web1,
50 mdebug=&sasjs_mdebug
51)
52
53%let status=0;
54data _null_;
55 set web1.sasparams;
56 putlog (_all_)(=);
57 if status='SUCCESS' then call symputx('status',1);
58 call symputx('dsid',dsid);
59run;
60
61%mp_assert(
62 iftrue=(&status=1 and &syscc=0),
63 desc=Checking successful submission,
64 outds=work.test_results
65)
66
67/**
68 * Now fetch the staged table with getstagetable
69 */
70data work.iwant;
71 table_id="&dsid";
72 output;
73run;
74
75%mx_execute(&appLoc/services/auditors/getstagetable,
76 viyacontext=&defaultcontext,
77 inputdatasets=work.iwant,
78 outlib=web2,
79 mdebug=&sasjs_mdebug
80)
81
82/* the staged table must be returned with our row in it */
83%let stagecheck=0;
84%let fmtcheck=0;
85data _null_;
86 set web2.stagetable;
87 if some_char='getstagetable test' and some_num=&maxpk+1
88 then call symputx('stagecheck',1);
89run;
90data _null_;
91 set web2.fmt_stagetable;
92 if some_char='getstagetable test' then call symputx('fmtcheck',1);
93run;
94
95/* the json libname can only be read once, so assert on the flags set
96 above rather than re-reading the tables */
97%mp_assert(
98 iftrue=(&stagecheck=1),
99 desc=getstagetable returns the staged table,
100 outds=work.test_results
101)
102%mp_assert(
103 iftrue=(&fmtcheck=1),
104 desc=getstagetable returns the formatted staged table,
105 outds=work.test_results
106)
107%mp_assert(
108 iftrue=(&stagecheck=1 and &fmtcheck=1),
109 desc=Checking staged changes present in both unformatted and formatted outputs,
110 outds=work.test_results
111)