def _add(year, month): year, month = int(year), int(month) with PathContext(): from config import DataFolder #download and unpack from download.download import RemoteFile remote = RemoteFile(year, month) assert remote.download() assert remote.unrar() # make interim csv from Word files interim_csv = DataFolder(year, month).get_interim_csv() if not os.path.exists(interim_csv): from word2csv.word import make_interim_csv assert make_interim_csv(year, month) assert DataFolder(year, month).copy_tab_csv() #parse, validate, save from csv2df.runner import Vintage vint = Vintage(year, month) assert vint.validate() assert vint.save()
def test_out_of_range_year_does_raises_error(self): with pytest.raises(ValueError): DataFolder(2030, 1)
def test_get_interim_csv_method_returns_existing_file(self): assert DataFolder(2015, 5).get_interim_csv().exists()
def test_raw_folder_may_not_be_present(self): assert DataFolder(2015, 5).get_raw_folder().exists()
def test_get_folder_methods_return_existing_folders(self): assert DataFolder(2015, 5).get_processed_folder().exists() assert DataFolder(2015, 5).get_interim_folder().exists()
def test_repr(self): assert repr(DataFolder(2015, 5))
def test_get_processed_property_method_returns_existing_folder(self): processed_folder = DataFolder(2015, 5).processed assert processed_folder.exists()
def test_get_interim_property_method_returns_existing_folder(self): interim_folder = DataFolder(2015, 5).interim assert interim_folder.exists()
def test_get_raw_property_method_returns_existing_folder(self): raw_folder = DataFolder(2015, 5).raw assert raw_folder.exists()
def test_repr_method_is_callable(self): assert repr(DataFolder(2015, 5))