def test_merge_flat_dictionary_keys_from_json_column(self):
        df = DataForTests.df_converter
        converter = Converter()
        result = converter.merge_flat_dictionary_keys_from_json_column(
            df, col_name='json')

        expected = ['client.phone', 'order.id', 'client.email']
        self.assertCountEqual(result, expected,
                              r'incorrect update for pattern \\\\ ')
 def test_not_extracted_json_col_by_regexp_2(self):
     converter = Converter()
     default_csv_line = ''
     line_number = -1
     line = '2333 Туту ЖД {"order":{"id":"111111111"},"client":{"email":"*****@*****.**"}} 2019-06-20 10:25:14'
     result = converter.not_extracted_json_col_by_regexp(
         default_csv_line, line, line_number)
     expected = ''
     self.assertEqual(result, expected, 'incorrect default data')
 def test_not_extracted_json_col_by_regexp(self):
     converter = Converter()
     default_csv_line = ''
     line_number = -1
     line = 'NULL	Туту ЖД		NULL	2019-06-20 10:25:14'
     result = converter.not_extracted_json_col_by_regexp(
         default_csv_line, line, line_number)
     expected = ''
     self.assertEqual(result, expected, 'incorrect default data')
 def test_get_csv_line_from_json(self):
     col_names = ["order.location", "client.email"]
     default_csv_line = ''
     converter = Converter()
     line_number = -1
     result = converter.get_csv_line_from_json(col_names, default_csv_line,
                                               self.json_load, line_number)
     expected = '"","*****@*****.**"'
     self.assertEqual(result, expected, 'incorrect default data')
 def test_get_csv_line_from_json_2(self):
     col_names = ["order.location", "client.phone", "client.email"]
     json_load = '{"client":{"phone": 923143, "email":"*****@*****.**"}}'
     default_csv_line = ''
     converter = Converter()
     line_number = -1
     result = converter.get_csv_line_from_json(col_names, default_csv_line,
                                               json_load, line_number)
     expected = '"","923143","*****@*****.**"'
     self.assertEqual(result, expected, 'incorrect default data')
 def test_write_json_column_to_csv_read_data_from_file(self):
     col_names = ["order.location", "client.email"]
     converter = Converter()
     converter.write_json_column_to_csv_read_data_from_file(
         self.input_file, col_names, self.output_file)
     f = open(self.output_file, 'r')
     file_read = f.read()
     result = [file_read]
     expected = [
         '"order.location","client.email"\n"","*****@*****.**"\n"ЧУП Самелго-Плюс Сак",'
         '"*****@*****.**"\n"",""\n'
     ]
     self.assertEqual(result, expected, 'incorrect default data')
 def test_write_json_column_to_csv(self):
     df = DataForTests.df_converter
     col_name = "json"
     col_names = ['client.phone', 'client.email']
     converter = Converter()
     converter.write_json_column_to_csv(df, col_name, col_names,
                                        self.output_file)
     f = open(self.output_file, 'r')
     file_read = f.read()
     result = [file_read]
     expected = [
         '"client.phone","client.email"\n"923143****","*****@*****.**"\n"","*****@*****.**"\n'
     ]
     self.assertEqual(result, expected, 'incorrect default data')