def test3_multi_data_file_export(): filename = '3_multi_data_file.data' filepath = test_file_path + filename data = {'k1':1, 'k2':2, 'k3':3} big_data = f"""\n\n# Comment data_b1 = {data} data_b2 = {data} data_b3 = {data} """ # Remove Any Existing Test File try: remove(filepath) except: pass time.sleep(file_delay_timer) # Test Not Exist, Create, Exist, Data and it's Type assert not path.exists(filepath) sfcparse.exportfile(filepath, f"data1 = {data}", f"\ndata2 = {data}", f"\ndata3 = {data}", big_data) assert path.exists(filepath) file_import = sfcparse.importfile(filepath) assert (file_import.data1 == {'k1':1, 'k2':2, 'k3':3}) and (type(file_import.data1) == type(dict())) assert (file_import.data2 == {'k1':1, 'k2':2, 'k3':3}) and (type(file_import.data2) == type(dict())) assert (file_import.data3 == {'k1':1, 'k2':2, 'k3':3}) and (type(file_import.data3) == type(dict())) assert (file_import.data_b1 == {'k1':1, 'k2':2, 'k3':3}) and (type(file_import.data_b1) == type(dict())) assert (file_import.data_b2 == {'k1':1, 'k2':2, 'k3':3}) and (type(file_import.data_b2) == type(dict())) assert (file_import.data_b3 == {'k1':1, 'k2':2, 'k3':3}) and (type(file_import.data_b3) == type(dict())) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass
def test1_basic_file_append(): filename = '1_basic_file_append.data' filepath = test_file_path + filename data = {'k1': 1, 'k2': 2, 'k3': 3} # Remove Any Existing Test File, then Create New One try: remove(filepath) except: pass time.sleep(file_delay_timer) assert not path.exists(filepath) sfcparse.exportfile(filepath) assert path.exists(filepath) # Test Single Line Append and Verify sfcparse.appendfile(filepath, f"data = {data}") file_import = sfcparse.importfile(filepath) assert (file_import.data == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data) == type(dict())) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass
def test2_multi_data_file_append(): filename = '2_multi_data_file.data' filepath = test_file_path + filename data = {'k1': 1, 'k2': 2, 'k3': 3} big_data = f"""\n\n# Comment data_b1 = {data} data_b2 = {data} data_b3 = {data} """ # Remove Any Existing Test File try: remove(filepath) except: pass time.sleep(file_delay_timer) assert not path.exists(filepath) sfcparse.exportfile(filepath) assert path.exists(filepath) # Test Multi Line Append and Verify sfcparse.appendfile(filepath, f"data1 = {data}", f"\ndata2 = {data}", f"\ndata3 = {data}", big_data) file_import = sfcparse.importfile(filepath) assert (file_import.data1 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data1) == type(dict())) assert (file_import.data2 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data2) == type(dict())) assert (file_import.data3 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data3) == type(dict())) assert (file_import.data_b1 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data_b1) == type(dict())) assert (file_import.data_b2 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data_b2) == type(dict())) assert (file_import.data_b3 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data_b3) == type(dict())) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass
def test3_data_tamper_file_append(): filename = '3_data_tamper_file.data' filepath = test_file_path + filename data = {'k1': 1, 'k2': 2, 'k3': 3} big_data = f"""# Comment data_b1 = {data} data_b2 = {data} data_b3 = {data}""" # Remove Any Existing Test File try: remove(filepath) except: pass time.sleep(file_delay_timer) assert not path.exists(filepath) # Export File with "Present Data" sfcparse.exportfile(filepath, big_data) assert path.exists(filepath) # Test Append Without Tampering Present Data and Verify. Appending 3x Lines sfcparse.appendfile(filepath, f"data1 = {data}", f"data2 = {data}", f"data3 = {data}") file_import = sfcparse.importfile(filepath) assert (file_import.data1 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data1) == type(dict())) assert (file_import.data2 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data2) == type(dict())) assert (file_import.data3 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data3) == type(dict())) assert (file_import.data_b1 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data_b1) == type(dict())) assert (file_import.data_b2 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data_b2) == type(dict())) assert (file_import.data_b3 == { 'k1': 1, 'k2': 2, 'k3': 3 }) and (type(file_import.data_b3) == type(dict())) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass
def test1_basic_file_export(): filename = '1_empty.data' filepath = test_file_path + filename # Remove Any Existing Test File try: remove(filepath) except: pass time.sleep(file_delay_timer) # Test Not Exist, Create, Exist assert not path.exists(filepath) sfcparse.exportfile(filepath) assert path.exists(filepath) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass
def test2_data_file_export(): filename = '2_data_file.data' filepath = test_file_path + filename data = {'k1':1, 'k2':2, 'k3':3} # Remove Any Existing Test File try: remove(filepath) except: pass time.sleep(file_delay_timer) # Test Not Exist, Create, Exist, Data and it's Type assert not path.exists(filepath) sfcparse.exportfile(filepath, f"data = {data}") assert path.exists(filepath) file_import = sfcparse.importfile(filepath) assert (file_import.data == {'k1':1, 'k2':2, 'k3':3}) and (type(file_import.data) == type(dict())) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass
def test1_default_format_export(): filename = '1_data_format.data' filepath = test_file_path + filename data = {'k1':1, 'k2':2, 'k3':3, 'k4':4, 'k5':5} # Remove Any Existing Test File try: remove(filepath) except: pass time.sleep(file_delay_timer) # Test Formatted Data then Export it and Read it data_formatted = sfcparse.cleanformat(data) assert not path.exists(filepath) sfcparse.exportfile(filepath, f"data = {data_formatted}") assert path.exists(filepath) file_import = sfcparse.importfile(filepath) assert (file_import.data == {'k1':1, 'k2':2, 'k3':3, 'k4':4, 'k5':5}) and (type(file_import.data) == type(dict())) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass
def test2_indent_format_export(): filename = '2_indent_format.data' filepath = test_file_path + filename data = {'k1':1, 'k2':2, 'k3':3, 'k4':4, 'k5':5} # Remove Any Existing Test File try: remove(filepath) except: pass time.sleep(file_delay_timer) # Test Formatted Data with Indent Change then Export it and Read it data_formatted1 = sfcparse.cleanformat(data, 0) data_formatted2 = sfcparse.cleanformat(data, 7) assert not path.exists(filepath) sfcparse.exportfile(filepath, f"data1 = {data_formatted1}") assert path.exists(filepath) sfcparse.appendfile(filepath, f"data2 = {data_formatted2}") file_import = sfcparse.importfile(filepath) assert (file_import.data1 == {'k1':1, 'k2':2, 'k3':3, 'k4':4, 'k5':5}) and (type(file_import.data1) == type(dict())) assert (file_import.data2 == {'k1':1, 'k2':2, 'k3':3, 'k4':4, 'k5':5}) and (type(file_import.data2) == type(dict())) # Remove Test File time.sleep(file_delay_timer) try: remove(filepath) except: pass