# Path: nacc/redcap2nacc.py
# def check_blanks(packet: uds3_packet.Packet, options: argparse.Namespace) \
# def blank_warnings(warnings, fieldname, formid, value, length, rule):
# def check_characters(packet: uds3_packet.Packet) -> typing.List:
# def check_for_bad_characters(field: Field) -> typing.List:
# def check_redcap_event(options, record) -> bool:
# def check_single_select(packet: uds3_packet.Packet):
# def empty(field):
# def exclusive(packet, fields, value_to_check=1):
# def set_blanks_to_zero(packet):
#     def set_to_zero_if_blank(*field_names):
# def convert(fp, options, out=sys.stdout, err=sys.stderr):
# def parse_args(args=None):
# def main():
# 
# Path: nacc/csf/builder.py
# def build_csf_form(record):
#     """ Converts REDCap CSV data into a packet (list of CSF Module objects) """
#     packet = csf_packet.Packet()
# 
#     # Set up the forms.
#     add_eE2(record, packet)
#     update_header(record, packet)
# 
#     return packet


import unittest
from nacc import redcap2nacc
from nacc.csf.builder import build_csf_form
    '''

    def setUp(self):
        self.options = option()

    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_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_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'

# Path: nacc/redcap2nacc.py
# def check_blanks(packet: uds3_packet.Packet, options: argparse.Namespace) \
# def blank_warnings(warnings, fieldname, formid, value, length, rule):
# def check_characters(packet: uds3_packet.Packet) -> typing.List:
# def check_for_bad_characters(field: Field) -> typing.List:
# def check_redcap_event(options, record) -> bool:
# def check_single_select(packet: uds3_packet.Packet):
# def empty(field):
# def exclusive(packet, fields, value_to_check=1):
# def set_blanks_to_zero(packet):
#     def set_to_zero_if_blank(*field_names):
# def convert(fp, options, out=sys.stdout, err=sys.stderr):
# def parse_args(args=None):
# def main():
# 
# Path: nacc/csf/builder.py
# def build_csf_form(record):
#     """ Converts REDCap CSV data into a packet (list of CSF Module objects) """
#     packet = csf_packet.Packet()
# 
#     # Set up the forms.
#     add_eE2(record, packet)
#     update_header(record, packet)
# 
#     return packet


# Path: tests/test_csf_blanks.py
import unittest
from nacc import redcap2nacc
from nacc.csf.builder import build_csf_form

    '''

    def setUp(self):
        self.options = option()

    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_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_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_csf_form(record)