def test_repr(self): zip = StatscanZip(RAIL_DATA_URL) print(zip) self.assertTrue("Statscan" in str(zip))
def test_create_from_url_with_params(self): dataset: StatscanZip = StatscanZip( 'https://www150.statcan.gc.ca/n1/en/tbl/csv/38100092-eng.zip?st=yQYQGvmD' ) self.assertIsNotNone(dataset)
def test_get_data_calls_fetch_once(self): url = "https://www150.statcan.gc.ca/n1/tbl/csv/23100274-eng.zip" zip: StatscanZip = StatscanZip(url) data = zip.get_data() self.assertGreater(len(data), 10)
def test_get_pivot_column(self): zip = StatscanZip(RAIL_DATA_URL) metadata: StatscanMetadata = zip.get_metadata() pivot_column = metadata.pivot_column() self.assertEqual('Indicator', pivot_column)
def test_get_data_multiple_times(self): zip = StatscanZip(RAIL_DATA_URL) data = zip.get_data() self.assertTrue("Companies" in data.columns) zip.get_data()
def test_get_dimensions(self): zip = StatscanZip(RAIL_DATA_URL) metadata: StatscanMetadata = zip.get_metadata() print(metadata.dimensions)
def test_get_metadata(self): zip = StatscanZip(RAIL_DATA_URL) metadata = zip.get_metadata() self.assertIsNotNone(metadata) self.assertIsNotNone(zip.metadata)
def test_ref_date(self): zip = StatscanZip( 'https://www150.statcan.gc.ca/n1/tbl/csv/23100274-eng.zip') data = zip.get_data() self.assertEqual(data.Date.dtype, '<M8[ns]')
def test_get_data(self): zip = StatscanZip(RAIL_DATA_URL) data = zip.get_data() self.assertTrue("Companies" in data.columns) self.assertTrue("Terminal dwell-time" in data.columns) self.assertTrue(len(data) > 60)
def download_prices(): return StatscanZip( 'https://www150.statcan.gc.ca/n1/tbl/csv/18100251-eng.zip').get_data()