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