postdata.test.1.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief testing postdata with mpe_x_test
4 
5  <h4> SAS Macros </h4>
6  @li mx_testservice.sas
7  @li mp_assert.sas
8 
9 
10 **/
11 
12 
13 /**
14  * First part - stage some data (for diffing)
15  */
16 data work.sascontroltable;
17  action='LOAD';
18  message="getdiffs prep";
19  libds="&dclib..MPE_X_TEST";
20  output;
21  stop;
22 run;
23 
24 proc sql noprint;
25 select max(primary_key_field) into: maxpk
26  from &dclib..mpe_x_test;
27 
28 data work.jsdata;
29  set &dclib..mpe_x_test(rename=(
30  some_date=dt2 SOME_DATETIME=dttm2 SOME_TIME=tm2)
31  );
32  /* for now, the adapter sends these as strings */
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_____='Yes';
39  output;
40  _____DELETE__THIS__RECORD_____='No';
41  some_char=' leadingblanks';
42  some_bestnum=._;
43  /* modify 1 record and add 4 more */
44  do primary_key_field=&maxpk to (&maxpk+5);
45  some_num=ranuni(0);
46  output;
47  end;
48  end;
49  else stop;
50 run;
51 
52 %mx_testservice(&appLoc/services/editors/stagedata,
53  viyacontext=&defaultcontext,
54  inputdatasets=work.jsdata work.sascontroltable,
55  outlib=web1,
56  mdebug=&sasjs_mdebug
57 )
58 
59 %let status=0;
60 data _null_;
61  set web1.sasparams;
62  putlog (_all_)(=);
63  if status='SUCCESS' then call symputx('status',1);
64  call symputx('dsid',dsid);
65 run;
66 
67 %mp_assert(
68  iftrue=(&status=1 and &syscc=0),
69  desc=Checking successful submission
70 )
71 
72 /**
73  * Now run postdata with SHOW_DIFFS
74  */
75 data work.sascontroltable;
76  ACTION='SHOW_DIFFS';
77  TABLE="&dsid";
78  DIFFTIME="%sysfunc(datetime(),B8601DT19.3)";
79  output;
80  stop;
81 run;
82 %mx_testservice(&appLoc/services/auditors/postdata,
83  viyacontext=&defaultcontext,
84  inputdatasets=work.sascontroltable,
85  outlib=web2,
86  outref=wbout,
87  mdebug=&sasjs_mdebug
88 )
89 
90 %let leadcheck=0;
91 %let speshcheck=0;
92 data _null_;
93  infile wbout;
94  input;
95  putlog _infile_;
96  /* the JSON libname engine removes leading blanks!!!! */
97  if index(_infile_,' leadingblanks') then call symputx('leadcheck',1);
98  /* there is no clean way to send a special missing - so is sent as string */
99  if index(_infile_,',"SOME_BESTNUM":"_"') then call symputx('speshcheck',1);
100 run;
101 
102 
103 %mp_assert(
104  iftrue=(&leadcheck=1),
105  desc=Checking leading blanks were applied
106 )
107 %mp_assert(
108  iftrue=(&leadcheck=1),
109  desc=Checking special characters were applied
110 )
111 
112 /* Now actually approve the table */
113 data work.sascontroltable;
114  ACTION='APPROVE_TABLE';
115  TABLE="&dsid";
116  /* difftime is numeric for approve action */
117  DIFFTIME="%sysfunc(datetime())";
118  output;
119  stop;
120 run;
121 %mx_testservice(&appLoc/services/auditors/postdata,
122  viyacontext=&defaultcontext,
123  inputdatasets=work.sascontroltable,
124  outlib=web3,
125  outref=wb3,
126  mdebug=&sasjs_mdebug
127 )
128 
129 %let status=0;
130 data _null_;
131  set web3.apparams;
132  putlog (_all_)(=);
133  if response='SUCCESS!' then call symputx('status',1);
134 run;
135 
136 %mp_assert(
137  iftrue=(&status=1 and &syscc=0),
138  desc=Checking successful submission
139 )