def test_like_build(self):
     from build import TYPES as TYPES, read_file
     data = {}
     for tp in TYPES.keys():
         temp = read_file(tp, self.YR, data_dir=self.DATA_DIR, **TYPES[tp]['args'])
         data[tp] = {i[TYPES[tp]['unique']]:i for i in temp}
         self.assertGreaterEqual(len(data[tp]),1)
         sys.stdout.flush()
    def test_cn(self):
        from build import read_file
        cn = read_file('cn', '16', data_dir=self.DATA_DIR)
        cand = {i['CAND_ID']:i for i in cn}
        assert len(cand) > 3

        self.assertEqual(cand['H0NH02017'],{'CAND_CITY': 'PETERBOROUGH',
               'CAND_ELECTION_YR': '2012',
               'CAND_ICI': 'C',
               'CAND_ID': 'H0NH02017',
               'CAND_NAME': 'BASS, CHARLES F.',
               'CAND_OFFICE': 'H',
               'CAND_OFFICE_DISTRICT': '02',
               'CAND_OFFICE_ST': 'NH',
               'CAND_PCC': 'C00302570',
               'CAND_PTY_AFFILIATION': 'REP',
               'CAND_ST': 'NH',
               'CAND_ST1': 'PO BOX 210',
               'CAND_ST2': '',
               'CAND_STATUS': 'P',
               'CAND_ZIP': '03458'})

        self.assertEqual(cand['H0MN08115'],{'CAND_CITY': 'ST PAUL',
               'CAND_ELECTION_YR': '2012',
               'CAND_ICI': 'C',
               'CAND_ID': 'H0MN08115',
               'CAND_NAME': 'CRAVAACK, RAYMOND J MR.',
               'CAND_OFFICE': 'H',
               'CAND_OFFICE_DISTRICT': '08',
               'CAND_OFFICE_ST': 'MN',
               'CAND_PCC': 'C00475632',
               'CAND_PTY_AFFILIATION': 'REP',
               'CAND_ST': 'MN',
               'CAND_ST1': 'PO BOX 40040',
               'CAND_ST2': '',
               'CAND_STATUS': 'P',
               'CAND_ZIP': '55101'})

        self.assertEqual(cand['H0MI01088'],{'CAND_CITY': 'CRYSTAL FALLS',
               'CAND_ELECTION_YR': '2016',
               'CAND_ICI': 'I',
               'CAND_ID': 'H0MI01088',
               'CAND_NAME': 'BENISHEK, DANIEL J. M.D.',
               'CAND_OFFICE': 'H',
               'CAND_OFFICE_DISTRICT': '01',
               'CAND_OFFICE_ST': 'MI',
               'CAND_PCC': 'C00476325',
               'CAND_PTY_AFFILIATION': 'REP',
               'CAND_ST': 'MI',
               'CAND_ST1': '802 PENTOGA TRAIL',
               'CAND_ST2': '',
               'CAND_STATUS': 'C',
               'CAND_ZIP': '499208518'})
    def test_pas(self):
        from build import read_file
        pas = read_file('pas2', '16', in_zip_filename= 'itpas2.txt', data_dir=self.DATA_DIR)
        ipas = {i['TRAN_ID']:i for i in pas}
        self.assertEqual(ipas['SB23.I21988'],{'AMNDT_IND': 'N',
                 'CAND_ID': 'H0IL10302',
                 'CITY': 'LIBERTYVILLE',
                 'CMTE_ID': 'C00305805',
                 'EMPLOYER': '',
                 'ENTITY_TP': 'CCM',
                 'FILE_NUM': '999281',
                 'IMAGE_NUM': '15951092984',
                 'MEMO_CD': '',
                 'MEMO_TEXT': '',
                 'NAME': 'DOLD FOR CONGRESS',
                 'OCCUPATION': '',
                 'OTHER_ID': 'C00465971',
                 'RPT_TP': 'M3',
                 'STATE': 'IL',
                 'SUB_ID': '4032320151240925784',
                 'TRANSACTION_AMT': '5000',
                 'TRANSACTION_DT': '02232015',
                 'TRANSACTION_PGI': 'P',
                 'TRANSACTION_TP': '24K',
                 'TRAN_ID': 'SB23.I21988',
                 'ZIP_CODE': '600488145'})

        self.assertEqual(ipas['SB23.9146'],{'AMNDT_IND': 'N',
               'CAND_ID': 'H0MI01088',
               'CITY': 'CRYSTAL FALLS',
               'CMTE_ID': 'C00330720',
               'EMPLOYER': '',
               'ENTITY_TP': 'CCM',
               'FILE_NUM': '1009653',
               'IMAGE_NUM': '15971199757',
               'MEMO_CD': '',
               'MEMO_TEXT': '',
               'NAME': 'BENISHEK FOR CONGRESS',
               'OCCUPATION': '',
               'OTHER_ID': 'C00476325',
               'RPT_TP': '30S',
               'STATE': 'MI',
               'SUB_ID': '4060520151244032747',
               'TRANSACTION_AMT': '2000',
               'TRANSACTION_DT': '05182015',
               'TRANSACTION_PGI': 'P',
               'TRANSACTION_TP': '24K',
               'TRAN_ID': 'SB23.9146',
               'ZIP_CODE': '49920'})
 def test_individual(self):
     from build import read_file
     ind_t = read_file('indiv', self.YR, in_zip_filename='itcont.txt', data_dir=self.DATA_DIR)
     ind = {i['SUB_ID']:i for i in ind_t}
     assert len(ind) > 3
     self.assertEqual(ind['4071720151247463287'], {'AMNDT_IND': 'N',
                      'CITY': 'MARQUETTE',
                      'CMTE_ID': 'C00476325',
                      'EMPLOYER': '',
                      'ENTITY_TP': 'IND',
                      'FILE_NUM': '1015681',
                      'IMAGE_NUM': '201507159000226039',
                      'MEMO_CD': '',
                      'MEMO_TEXT': '',
                      'NAME': 'FARBOD, JEAN L. DR.',
                      'OCCUPATION': '',
                      'OTHER_ID': '',
                      'RPT_TP': 'Q2',
                      'STATE': 'MI',
                      'SUB_ID': '4071720151247463287',
                      'TRANSACTION_AMT': '250',
                      'TRANSACTION_DT': '04072015',
                      'TRANSACTION_PGI': 'P',
                      'TRANSACTION_TP': '22Y',
                      'TRAN_ID': 'B7763216465004035A6B',
                      'ZIP_CODE': '49855'})
     self.assertEqual(ind['4071720151247404714'],{'AMNDT_IND': 'N',
                      'CITY': 'BANNING',
                      'CMTE_ID': 'C00476325',
                      'EMPLOYER': '',
                      'ENTITY_TP': 'ORG',
                      'FILE_NUM': '1015681',
                      'IMAGE_NUM': '201507159000225949',
                      'MEMO_CD': '',
                      'MEMO_TEXT': '',
                      'NAME': 'MORONGO BAND OF MISSION INDIANS',
                      'OCCUPATION': '',
                      'OTHER_ID': '',
                      'RPT_TP': 'Q2',
                      'STATE': 'CA',
                      'SUB_ID': '4071720151247404714',
                      'TRANSACTION_AMT': '1000',
                      'TRANSACTION_DT': '06012015',
                      'TRANSACTION_PGI': 'P',
                      'TRANSACTION_TP': '11',
                      'TRAN_ID': 'AC93EF91A931D4EA6981',
                      'ZIP_CODE': '922206977'})
 def test_cm(self):
     from build import read_file
     print('a')
     cm = read_file('cm', '16', data_dir=self.DATA_DIR)
     comm = {i['CMTE_ID']:i for i in cm}
     self.assertEqual(comm['C00001461']['CMTE_NM'],'ALASKA STATE MEDICAL ASSOCIATION POLITICAL ACTION COMMITTEE (ALPAC)')
     self.assertEqual(comm['C00001461'],{'CAND_ID': '',
      'CMTE_CITY': 'ANCHORAGE',
      'CMTE_DSGN': 'U',
      'CMTE_FILING_FREQ': 'Q',
      'CMTE_ID': 'C00001461',
      'CMTE_NM': 'ALASKA STATE MEDICAL ASSOCIATION POLITICAL ACTION COMMITTEE '
                 '(ALPAC)',
      'CMTE_PTY_AFFILIATION': '',
      'CMTE_ST': 'AK',
      'CMTE_ST1': '4107 LAUREL STREET',
      'CMTE_ST2': '',
      'CMTE_TP': 'Q',
      'CMTE_ZIP': '99508',
      'CONNECTED_ORG_NM': 'ALASKA STATE MEDICAL ASSOCIATION',
      'ORG_TP': 'M',
      'TRES_NM': 'ELLERBE, DWIGHT DR. '})
 def test_FileChecker(self):
     from build import read_file
     #Regular Sample File
     res = read_file('cm', '16', data_dir=self.DATA_DIR)
     self.assertTrue(len(res) == 22)