def test_should_convert_to_dictionary(self):
        polling_station = PollingStation(1, 01, "APAC", 002, "KWANIA COUNTY", 01, "ADUKU", 01, "ADYEDA", 01,
                                         "ADYEDA CENTRE")
        self.expected_dict = {"NO": 1, "DIST_CODE": 1, "DISTRICT_NAME": "APAC", "EA_CODE": 2,
                              "EA_NAME": "KWANIA COUNTY", "SUB_COUNTY_CODE": 1, "SUB_COUNTY_NAME": "ADUKU",
                              "PARISH_CODE": 1, "PARISH_NAME": "ADYEDA",
                              "PS_CODE": 1, "POLLING_STATION_NAME": "ADYEDA CENTRE"}

        self.assertEqual(polling_station.to_dict(), self.expected_dict)
    def excel_to_json(self, file_path):
        work_book = load_workbook(file_path)
        work_book._active_sheet_index = 0
        work_sheet = work_book.active

        polling_stations = []
        for row in work_sheet.rows:
            if self.is_valid(row):
                polling_station = PollingStation(row[0].value, row[1].value, row[2].value, row[3].value, row[4].value,
                                                 row[5].value, row[6].value, row[7].value, row[8].value,
                                                 # TODO: an unknown cell is added in the 9th position, so skip it
                                                 row[10].value, row[11].value)
                polling_stations.append(polling_station.to_dict())

        return json.dumps(polling_stations)
    def excel_to_json(self, file_path):
        work_book = load_workbook(file_path)
        work_book._active_sheet_index = 0
        work_sheet = work_book.active

        polling_stations = []
        for row in work_sheet.rows:
            if self.is_valid(row):
                polling_station = PollingStation(
                    row[0].value,
                    row[1].value,
                    row[2].value,
                    row[3].value,
                    row[4].value,
                    row[5].value,
                    row[6].value,
                    row[7].value,
                    row[8].value,
                    # TODO: an unknown cell is added in the 9th position, so skip it
                    row[10].value,
                    row[11].value)
                polling_stations.append(polling_station.to_dict())

        return json.dumps(polling_stations)