<gh_stars>0
import os
import unittest
from peru import peru

_SOURCE_ID = "place_holder_ID"
_SOURCE_URL = "place_holder_URL"


class PeruTest(unittest.TestCase):
    def setUp(self):
        self.maxDiff = 5000

    def test_parse(self):
        '''
        Includes a row where province and district are unspecified, where it should return just
        the department and country
        '''
        current_dir = os.path.dirname(__file__)
        sample_data_file = os.path.join(current_dir, "sample_data.csv")

        result = peru.parse_cases(sample_data_file, _SOURCE_ID, _SOURCE_URL)
        self.assertCountEqual(list(result),
                              [{'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '7320cabdc1aaca6c59014cae76a134e6',
                                                  'sourceUrl': 'place_holder_URL'},
                                'location': {'query': 'LIMA, LIMA, SAN JUAN DE MIRAFLORES, Peru'},
                                'events': [{'name': 'confirmed',
                                            'value': 'PCR test',
                                            'dateRange': {'start': '08/25/2020Z',
                                                          'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 50.0,
                                                                'end': 50.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'e81602051997ace8340bb8c18fe24c65',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'AREQUIPA, AREQUIPA, CAYMA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 44.0,
                                                                'end': 44.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'cecdbf10074dbc011ae05b3cbd320a6f',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'CUSCO, CUSCO, SAN JERONIMO, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 49.0,
                                                                'end': 49.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '71ecb6bccb248b0bb2ac72ed51b5e979',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, INDEPENDENCIA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 49.0,
                                                                'end': 49.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '566af4276cbe9359abe93f9aa86396c3',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'ICA, ICA, ICA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 43.0,
                                                                'end': 43.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '027561e9d126e7c283d79c02cede562d',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, LOS OLIVOS, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 41.0,
                                                                'end': 41.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'f016889b9ba5bd95cf15d60205cbd82e',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'APURIMAC, CHINCHEROS, CHINCHEROS, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 42.0,
                                                                'end': 42.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '971f8e1295583756d81fe42f3318488c',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, SAN MARTIN DE PORRES, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 42.0,
                                                                'end': 42.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'bc45b71b005a96f32eeb97060616a999',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, LA VICTORIA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 72.0,
                                                                'end': 72.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '0e2a1928ddd07d99978758e86b034131',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, SAN JUAN DE MIRAFLORES, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 35.0,
                                                                'end': 35.0},
                                                   'gender': 'Female'}}])

import os
import unittest
from peru import peru

_SOURCE_ID = "place_holder_ID"
_SOURCE_URL = "place_holder_URL"


class PeruTest(unittest.TestCase):
    def setUp(self):
        self.maxDiff = 5000

    def test_parse(self):
        '''
        Includes a row where province and district are unspecified, where it should return just
        the department and country
        '''
        current_dir = os.path.dirname(__file__)
        sample_data_file = os.path.join(current_dir, "sample_data.csv")

        result = peru.parse_cases(sample_data_file, _SOURCE_ID, _SOURCE_URL)
        self.assertCountEqual(list(result),
                              [{'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '7320cabdc1aaca6c59014cae76a134e6',
                                                  'sourceUrl': 'place_holder_URL'},
                                'location': {'query': 'LIMA, LIMA, SAN JUAN DE MIRAFLORES, Peru'},
                                'events': [{'name': 'confirmed',
                                            'value': 'PCR test',
                                            'dateRange': {'start': '08/25/2020Z',
                                                          'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 50.0,
                                                                'end': 50.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'e81602051997ace8340bb8c18fe24c65',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'AREQUIPA, AREQUIPA, CAYMA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 44.0,
                                                                'end': 44.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'cecdbf10074dbc011ae05b3cbd320a6f',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'CUSCO, CUSCO, SAN JERONIMO, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 49.0,
                                                                'end': 49.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '71ecb6bccb248b0bb2ac72ed51b5e979',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, INDEPENDENCIA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 49.0,
                                                                'end': 49.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '566af4276cbe9359abe93f9aa86396c3',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'ICA, ICA, ICA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 43.0,
                                                                'end': 43.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '027561e9d126e7c283d79c02cede562d',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, LOS OLIVOS, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 41.0,
                                                                'end': 41.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'f016889b9ba5bd95cf15d60205cbd82e',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'APURIMAC, CHINCHEROS, CHINCHEROS, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 42.0,
                                                                'end': 42.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '971f8e1295583756d81fe42f3318488c',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, SAN MARTIN DE PORRES, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 42.0,
                                                                'end': 42.0},
                                                   'gender': 'Female'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': 'bc45b71b005a96f32eeb97060616a999',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, LA VICTORIA, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 72.0,
                                                                'end': 72.0},
                                                   'gender': 'Male'}},
                               {'caseReference': {'sourceId': 'place_holder_ID',
                                                  'sourceEntryId': '0e2a1928ddd07d99978758e86b034131',
                                                  'sourceUrl': 'place_holder_URL'},
                                  'location': {'query': 'LIMA, LIMA, SAN JUAN DE MIRAFLORES, Peru'},
                                  'events': [{'name': 'confirmed',
                                              'value': 'PCR test',
                                              'dateRange': {'start': '08/25/2020Z',
                                                            'end': '08/25/2020Z'}}],
                                  'demographics': {'ageRange': {'start': 35.0,
                                                                'end': 35.0},
                                                   'gender': 'Female'}}])
Includes a row where province and district are unspecified, where it should return just         the department and country