Exemplo n.º 1
0
    def test_download(self):
        for city in self.test_cities:
            city_data = systems.get_city_by_name(city[0], city[1])

            t, failures = download.save(city[0], city[1], should_archive=True)

            self.assertEqual(len(failures), 0)

            file_absolute = files.get_file_path(city_data, t)
            file_current = files.get_current_file_path(city_data)

            self.assertTrue(os.path.exists(file_absolute))
            self.assertTrue(os.path.exists(file_current))
Exemplo n.º 2
0
    def test_download(self):
        """
        Test that downloading the data results in physical file being created
        for all systems specified.
        """
        for city in self.test_cities:
            city_data = systems.get_city_by_name(city[0], city[1])

            t, failures = download.save(city[0], city[1], should_archive=True)

            self.assertEqual(len(failures), 0)

            file_absolute = files.get_file_path(city_data, t)
            file_current = files.get_current_file_path(city_data)

            self.assertTrue(os.path.exists(file_absolute))
            self.assertTrue(os.path.exists(file_current))
Exemplo n.º 3
0
    def test_download_create_dir(self):
        # tests that script will attempt to create data directories
        # if they don't exist
        import shutil

        city_data = {'system': 'sharengo', 'name': 'milano'}
        data_dir = files.get_data_dir(city_data)

        # delete if already exists
        if os.path.exists(data_dir):
            shutil.rmtree(data_dir)

        # download
        t, failures = download.save(city_data['system'], city_data['name'], False)
        file_current = files.get_current_file_path(city_data)

        # test it was downloaded
        self.assertEqual(len(failures), 0)
        self.assertTrue(os.path.exists(file_current))
Exemplo n.º 4
0
    def test_download_create_dir(self):
        """
        Tests that downloader will attempt to create data directories
        if they don't exist.
        """
        import shutil

        city_data = {'system': 'sharengo', 'name': 'milano'}
        data_dir = files.get_data_dir(city_data)

        # delete if already exists
        if os.path.exists(data_dir):
            shutil.rmtree(data_dir)

        # download
        t, failures = download.save(city_data['system'], city_data['name'], False)
        file_current = files.get_current_file_path(city_data)

        # test it was downloaded
        self.assertEqual(len(failures), 0)
        self.assertTrue(os.path.exists(file_current))