Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import io 

2import json 

3import logging 

4import os 

5import sys 

6from sdc_etl_libs.sdc_data_schema.schema_toolbox import SchemaToolbox 

7from sdc_etl_libs.sdc_file_helpers.SDCFileFactory import SDCFileFactory 

8import pytest 

9 

10data_schema_1 = json.loads(open(os.path.dirname(os.path.abspath(__file__)) + "/test_schema_avro_file.json").read()) 

11ep_schema_1 = SchemaToolbox.get_endpoint_data_from_schema(data_schema_1, "main_source", validate_=True) 

12 

13 

14@pytest.mark.skip(reason="Resolve this avro test as it is currently not returning a DF") 

15def test_get_avro_file_as_dataframe(): 

16 """ 

17 Test loading avro file as dataframe 

18 """ 

19 #TODO: Resolve this avro test when we get back to avro ETL 

20 with open(os.path.dirname(os.path.abspath(__file__)) + "/test.avro", "rb") as fp: 

21 sdc_file = SDCFileFactory.get_file(data_schema_1, ep_schema_1, "heap-users", "Heap/", fp) 

22 df = sdc_file.get_file_as_dataframe() 

23 assert df.df is not None 

24 

25def test_get_bad_avro_file_as_dataframe(): 

26 """ 

27 Test loading avro file as dataframe 

28 """ 

29 with open(os.path.dirname(os.path.abspath(__file__)) + "/test_bad.avro", "rb") as fp: 

30 sdc_file = SDCFileFactory.get_file(data_schema_1, ep_schema_1, "heap-users", "Heap/", fp) 

31 df = sdc_file.get_file_as_dataframe() 

32 assert df.df is None