-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V1.4 : merge this PR once the updates are up on SSC
- Loading branch information
Showing
20 changed files
with
1,719 additions
and
1,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,3 @@ run/ | |
admin/ | ||
*.xls | ||
*.xlsx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
MASTER RUN FILE | ||
This file is meant to be used to test the commands before a new release. | ||
It should not be merged to the Master branch, just kept on develop so it | ||
can be used before making a new PR. | ||
*******************************************************************************/ | ||
|
||
|
||
qui { | ||
/******************************************************************************* | ||
Part I: Set up | ||
*******************************************************************************/ | ||
|
||
* Set folder paths | ||
global GitHub "" | ||
global AnalyticsDB "" | ||
|
||
* Calculate globals | ||
global iefieldkit "${GitHub}/iefieldkit" | ||
global form "${AnalyticsDB}/Data Coordinator/iefieldkit/ietestform" | ||
|
||
* Select commands to test | ||
local ieduplicates 1 | ||
local iecompdup 1 | ||
local ietestform 1 | ||
local iecodebook 0 | ||
local iefieldkit 0 | ||
|
||
/******************************************************************************* | ||
Part II: Test inputs | ||
*******************************************************************************/ | ||
|
||
if "${GitHub}" == "" { | ||
noi di as error "Add the folder path to your GitHub folder to the Master run file." | ||
exit | ||
} | ||
if !inlist(1, `ieduplicates', `iecompdup', `ietestform', `iecodebook', `iefieldkit') { | ||
noi di as error "No commands to test" | ||
exit | ||
} | ||
} | ||
|
||
/******************************************************************************* | ||
Part III: Test commands | ||
*******************************************************************************/ | ||
|
||
* Test ieduplicates | ||
if `ieduplicates' do "${iefieldkit}/run/ieduplicates.do" | ||
|
||
* Test iecompdup | ||
if `iecompdup' do "${iefieldkit}/run/ieduplicates.do" | ||
|
||
* Test ietestform | ||
if `ietestform' do "${iefieldkit}/run/ietestform.do" | ||
|
||
*************************** End of Master Do-File ****************************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
do "${GitHub}/iefieldkit/src/ado_files/iecompdup.ado" | ||
|
||
/******************************************************************************* | ||
Prepare data | ||
*******************************************************************************/ | ||
|
||
sysuse auto, clear | ||
|
||
encode make, gen(uuid) | ||
|
||
* Two duplicates | ||
replace uuid = 1 if (uuid <= 2) | ||
|
||
* Three duplicates | ||
replace uuid = 2 if (uuid > 1 & uuid <= 5) | ||
|
||
* Four duplicates | ||
replace uuid = 3 if (uuid > 2 & uuid <= 9) | ||
|
||
gen key = _n | ||
gen wrong_key = key | ||
replace wrong_key = 2 if uuid == 2 | ||
gen oi = "oi" | ||
|
||
tempfile testdata | ||
save `testdata' | ||
|
||
|
||
/******************************************************************************* | ||
Should return no error | ||
*******************************************************************************/ | ||
|
||
*------------------------------------------------------------------------------- | ||
* Two duplicates | ||
*------------------------------------------------------------------------------- | ||
|
||
iecompdup uuid, id(1) | ||
iecompdup uuid, id(1) didiff | ||
iecompdup uuid, id(1) didiff keepdiff | ||
|
||
use `testdata', clear | ||
iecompdup uuid, id(1) keepdiff keepother(oi) | ||
|
||
*------------------------------------------------------------------------------- | ||
* More than two duplicates | ||
*------------------------------------------------------------------------------- | ||
|
||
* With string key | ||
use `testdata', clear | ||
iecompdup uuid if inlist(make, "Audi 5000", "Audi Fox"), id(2) | ||
iecompdup uuid if inlist(make, "Audi 5000", "Audi Fox"), id(2) didiff keepdiff | ||
|
||
* With numeric key | ||
iecompdup uuid if inlist(key, 53, 54 ), id(2) | ||
iecompdup uuid if inlist(key, 53, 54 ), id(2) didiff keepdiff | ||
|
||
* With more2ok | ||
use `testdata', clear | ||
iecompdup uuid, id(2) more2ok | ||
iecompdup uuid, id(2) more2ok didiff keepdiff | ||
|
||
|
||
/******************************************************************************* | ||
Should return error | ||
*******************************************************************************/ | ||
|
||
use `testdata', clear | ||
|
||
*------------------------------------------------------------------------------- | ||
* No duplicates | ||
*------------------------------------------------------------------------------- | ||
|
||
cap iecompdup uuid, id(15) | ||
assert _rc == 2001 | ||
|
||
cap iecompdup uuid if key == 210938, id(0) | ||
assert _rc == 2000 | ||
|
||
*------------------------------------------------------------------------------- | ||
* Options incorrectly specified | ||
*------------------------------------------------------------------------------- | ||
|
||
cap iecompdup uuid, id(1) keepother(oi) | ||
assert _rc == 197 | ||
|
||
*------------------------------------------------------------------------------- | ||
* More than two duplicates | ||
*------------------------------------------------------------------------------- | ||
|
||
cap iecompdup uuid, id(2) | ||
assert _rc == 197 | ||
|
||
cap iecompdup uuid if inlist(key, 53, 54, 3), id(2) | ||
assert _rc == 197 | ||
|
||
*------------------------------------------------------------------------------- | ||
* An ID value is numeric but not an integer. | ||
*------------------------------------------------------------------------------- | ||
|
||
replace uuid = 1.5 if (uuid == 1) | ||
cap iecompdup uuid, id(1.5) | ||
assert _rc == 109 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
/******************************************************************************* | ||
Set up | ||
*******************************************************************************/ | ||
|
||
* Add the path to your local clone of the iefieldkit repo | ||
do "${iefieldkit}/src/ado_files/ieduplicates.ado" | ||
|
||
|
||
sysuse auto, clear | ||
encode make, gen(uuid) | ||
replace uuid = 7 in 16 | ||
replace uuid = 1 in 2 | ||
|
||
tempfile duplicates | ||
save `duplicates' | ||
|
||
/******************************************************************************* | ||
No error | ||
*******************************************************************************/ | ||
|
||
* No duplicates | ||
ieduplicates make using "${iefieldkit}\foo", uniquevars(make) | ||
|
||
* Test file format | ||
use `duplicates', clear | ||
ieduplicates uuid using "${iefieldkit}\foo.xlsx", uniquevars(make) force | ||
|
||
use `duplicates', clear | ||
ieduplicates uuid using "${iefieldkit}\foo.xls", uniquevars(make) force | ||
|
||
* Test folder and suffix syntax | ||
use `duplicates', clear | ||
ieduplicates uuid, uniquevars(make) folder("${iefieldkit}") force | ||
|
||
use `duplicates', clear | ||
ieduplicates uuid, uniquevars(make) folder("${iefieldkit}") suffix(bar) force | ||
|
||
|
||
/******************************************************************************* | ||
Yes error | ||
*******************************************************************************/ | ||
|
||
* Observations were removed | ||
cap ieduplicates uuid using "${iefieldkit}", uniquevars(make) | ||
assert _rc == 9 | ||
|
||
* Without 'clear' option | ||
use `duplicates', clear | ||
cap ieduplicates uuid using "${iefieldkit}\foo", uniquevars(make) | ||
assert _rc == 198 | ||
|
||
* Invalid format | ||
use `duplicates', clear | ||
cap ieduplicates uuid using "${iefieldkit}\foo.csv", uniquevars(make) | ||
assert _rc == 198 | ||
|
||
use `duplicates', clear | ||
cap ieduplicates uuid using "${iefieldkit}\foo.", uniquevars(make) force | ||
assert _rc == 198 | ||
|
||
* Invalid name | ||
use `duplicates', clear | ||
cap ieduplicates uuid using "${iefieldkit}\.xlsx", uniquevars(make) | ||
assert _rc == 198 | ||
|
||
*Check that cd is not working | ||
cd "${iefieldkit}" | ||
use `duplicates', clear | ||
cap ieduplicates uuid using "foo", uniquevars(make) force | ||
assert _rc == 198 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
do "${GitHub}/iefieldkit/src/ado_files/ietestform.ado" | ||
|
||
|
||
/******************************************************************************* | ||
Should return no error | ||
*******************************************************************************/ | ||
|
||
ietestform using "$form/ietestform_surveyform.xlsx", /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date | ||
|
||
/******************************************************************************* | ||
Should return error | ||
*******************************************************************************/ | ||
*------------------------------------------------------------------------------- | ||
* Including using and survey form in same code | ||
*------------------------------------------------------------------------------- | ||
|
||
cap ietestform using "$form/ietestform_surveyform.xlsx", /// | ||
surveyform("$form/ietestform_surveyform.xlsx") /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date | ||
assert _rc == 198 | ||
|
||
*------------------------------------------------------------------------------- | ||
* Missing "using" | ||
*------------------------------------------------------------------------------- | ||
|
||
cap ietestform "$form/ietestform_surveyform.xlsx", /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date | ||
assert _rc == 101 | ||
|
||
*------------------------------------------------------------------------------- | ||
* Missing file extenstion | ||
*------------------------------------------------------------------------------- | ||
|
||
cap ietestform using "$form/ietestform_surveyform", /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date | ||
assert _rc == 601 | ||
|
||
cap ietestform using "$form/ietestform_surveyform.xlsx", /// | ||
reportsave("$form/ietestform_result.") /// | ||
replace /// | ||
date | ||
assert _rc == 601 | ||
|
||
*------------------------------------------------------------------------------- | ||
* Incorrect file extenstion | ||
*------------------------------------------------------------------------------- | ||
|
||
cap ietestform using "$form/ietestform_surveyform.xls", /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date | ||
assert _rc == 601 | ||
|
||
cap ietestform using "$form/ietestform_surveyform.xsl", /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date | ||
assert _rc == 601 | ||
|
||
cap ietestform using "$form/ietestform_surveyform.xlsx", /// | ||
reportsave("$form/ietestform_result.cvs") /// | ||
replace /// | ||
date | ||
assert _rc == 601 | ||
|
||
|
||
*------------------------------------------------------------------------------- | ||
* Stata label doesn't exist | ||
*------------------------------------------------------------------------------- | ||
|
||
cap ietestform using "$form/ietestform_surveyform.xlsx", /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date /// | ||
statalanguage(stata) | ||
assert _rc == 198 | ||
|
||
*------------------------------------------------------------------------------- | ||
* Stata label incorrectly specified | ||
*------------------------------------------------------------------------------- | ||
|
||
cap ietestform using "$form/ietestform_surveyform.xlsx", /// | ||
reportsave("$form/ietestform_result.csv") /// | ||
replace /// | ||
date /// | ||
statalanguage(Stata) | ||
assert _rc == 198 | ||
|
Oops, something went wrong.