'Tests the scan_file function.'

def test_scan_file(self):

    exts = ('.shp', '.shx', '.sld', '.xml', '.prj', '.dbf')
    with create_files(map((lambda s: 'san_andres_y_providencia_location{0}'.format(s)), exts)) as tests:
        shp = filter((lambda s: s.endswith('.shp')), tests)[0]
        spatial_files = scan_file(shp)
        self.assertTrue(isinstance(spatial_files, SpatialFiles))
        spatial_file = spatial_files[0]
        self.assertEqual(shp, spatial_file.base_file)
        self.assertTrue(spatial_file.file_type.matches('shp'))
        self.assertEqual(len(spatial_file.auxillary_files), 3)
        self.assertEqual(len(spatial_file.xml_files), 1)
        self.assertTrue(all(map((lambda s: s.endswith('xml')), spatial_file.xml_files)))
        self.assertEqual(len(spatial_file.sld_files), 1)
        self.assertTrue(all(map((lambda s: s.endswith('sld')), spatial_file.sld_files)))
    file_names = ['109029_23.shp', '109029_23.shx', '109029_23.dbf', '109029_23.prj', '109029_23.xml', '109029_23.sld']
    with create_files(file_names, zipped=True) as tests:
        spatial_files = scan_file(tests[0])
        self.assertTrue(isinstance(spatial_files, SpatialFiles))
        spatial_file = spatial_files[0]
        self.assertTrue(spatial_file.file_type.matches('shp'))
        self.assertEqual(len(spatial_file.auxillary_files), 3)
        self.assertEqual(len(spatial_file.xml_files), 1)
        self.assertEqual(len(spatial_file.sld_files), 1)
        self.assertTrue(all(map((lambda s: s.endswith('xml')), spatial_file.xml_files)))
        basedir = os.path.dirname(spatial_file.base_file)
        for f in file_names:
            path = os.path.join(basedir, ('_%s' % f))
            self.assertTrue(os.path.exists(path))
