def test_for_multiple_error_CSFABmDX(self): ''' CSFABmDX must be left blank if CSFABmD is not "other," but also when CSFABETA is left blank. This is testing both rules at the same time.''' record = make_filled_form() record['csfabeta'] = '' record['csfabmo'] = '' record['csfabdy'] = '' record['csfabyr'] = '' record['csfabmd'] = '2' record['csfabmdx'] = 'test' ipacket = build_uds3_csf_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = ["'CSFABmD' is '2' with length '1', but should be blank:" " 'Blank if Question 1a CSFABETA = blank'.", "'CSFABmDX' is 'test " " ' with length '60', but should be" " blank: 'Blank if Question 1e CSFABmD ne 8 (Other)'.", "'CSFABmDX' is 'test " " ' with length '60', but should be" " blank: 'Blank if Question 1a CSFABETA = blank'."] # Since CSFABETA is blank, CSFABmD should technically also be blank, # so the first error is also returned. self.assertEqual(warnings, expected)
def test_for_FTDPABVF_blank(self): record = make_filled_form() record['ftdpabvf'] = '9' record['ftdbvft'] = '' ipacket = build_uds3_ftld_ivp_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = [ "'FTDPABVF' is '9' with length '1', but should be blank:" " 'Blank if Question 22 FTDBVFT = blank'." ] self.assertEqual(warnings, expected)
def test_for_single_error_CSFABmDX(self): ''' CSFABmDX is a field where you specify what "other" assay method was used. ''' record = make_filled_form() record['csfabmd'] = '2' record['csfabmdx'] = 'test' ipacket = build_uds3_csf_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = ["'CSFABmDX' is 'test " " ' with length '60', but should be" " blank: 'Blank if Question 1e CSFABmD ne 8 (Other)'."] self.assertEqual(warnings, expected)
def test_for_filled_when_ruled_blank(self): # Have it look for the langa4 error to see that general blanking rules # are working (langa4 also comes before the variable (a4sub) # it's dependent on) record = make_filled_form() record['a4sub'] = '0' record['langa4'] = '1' ipacket = build_uds3_ftld_ivp_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = [ "'LANGA4' is '1' with length '1', but should be blank:" " 'Blank if Question 4b A4SUB = 0 (No)'." ] self.assertEqual(warnings, expected)
def test_for_special_case_FTDCPC2F(self): ''' One packet of questions should be left blank if FTDCPC2F has a value (anything between 95-98) ''' record = make_filled_form() record['ftdcpc2f'] = '95' record['ftdhaird'] = '1' ipacket = build_uds3_ftld_ivp_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = [ "'FTDhAIRD' is '1' with length '1', but should be blank:" " 'Blank if Question 0 FTDCPC2F = 95'." ] self.assertEqual(warnings, expected)
def test_for_blank_form_when_CSFABETA(self): ''' The whole set of questions should be left blank if CSFABETA is blank. ''' record = make_filled_form() record['csfabeta'] = '' ipacket = build_uds3_csf_form(record) warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = ["'CSFABmo' is '1 ' with length '2', but should be blank:" " 'Blank if Question 1a CSFABETA = blank'.", "'CSFABDY' is" " '12' with length '2', but should be blank: 'Blank if" " Question 1a CSFABETA = blank'.", "'CSFABYr' is '1990'" " with length '4', but should be blank: 'Blank if Question" " 1a CSFABETA = blank'.", "'CSFABmD' is '2' with length" " '1', but should be blank: 'Blank if Question 1a" " CSFABETA = blank'."] self.assertEqual(warnings, expected)
def test_for_FTDPABVF_0(self): ''' Have it make sure _blanking_rule_for_others_left_blank is working by checking both 0 and False instances (it will skip if either of these is the case for two questions) ''' record = make_filled_form() record['ftdpabvf'] = '9' record['ftdcppa'] = '0' ipacket = build_uds3_ftld_ivp_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = [ "'FTDPABVF' is '9' with length '1', but should be blank:" " 'Blank if Question 12 FTDCPPA = 0 (No) '." ] self.assertEqual(warnings, expected)
def test_for_single_blanking_rule_returned(self): ''' Have it make sure that only one error is returned from a list of rules when not working with special cases (special cases need a fix in a later feature branch) ''' record = make_filled_form() record['ftdcppas'] = '******' record['ftdcppa'] = '' record['ftdpabvf'] = '' record['ftdppasl'] = '0' ipacket = build_uds3_ftld_ivp_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = [ "'FTDCPPAS' is '2' with length '1', but should be blank:" " 'Blank if Question 1 FTDPPASL = 0 (No)'." ] self.assertEqual(warnings, expected)
def test_for_special_case_or2(self): ''' Have it make sure _blanking_rule_ftld_or2 works properly (and by extension or3, or4, and or5) - This blanking rule depends on either of two possible answers to questions, along with regular blanking rules ''' record = make_filled_form() record['ftdmrirf'] = '0' record['ftdmrifa'] = '9' record['ftdmriob'] = '' ipacket = build_uds3_ftld_ivp_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) expected = [ "'FTDMRIRF' is '0' with length '1', but should be blank: " "'Blank if Question 2a, FTDMRIFA, = 0 (No) or 9" " (Unknown)'." ] self.assertEqual(warnings, expected)
def test_for_special_case_FTDMRIOS(self): ''' Have it make sure _blanking_rule_ftld_or2a works properly - This blanking rule has an extra condition added to the or2 rules (packet['FTDMRIOB'] != 1) ''' record = make_filled_form() record['ftdmrios'] = '1' record['ftdmriob'] = '0' ipacket = build_uds3_ftld_ivp_form(record) warnings = [] warnings = redcap2nacc.check_blanks(ipacket, self.options) # FTDMRIOS is a Char field with a length of 60 characters expected = [ "'FTDMRIOS' is" " '1 " " ' with length '60', but should be blank:" " 'Blank if Question 2a11 FTDMRIOB ne 1 (Yes)'." ] self.assertEqual(warnings, expected)