# 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 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)
        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_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_csf_form(record)
        warnings = []


# 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 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)
        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_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_csf_form(record)
        warnings = []


        warnings = redcap2nacc.check_blanks(ipacket, self.options)