Ejemplo n.º 1
0
    def test_delete_succcessful(self):
        ''' need to delete timezone_modified.csv first'''
        if os.path.exists('../input_csv_files/timezone_modified.csv'):
            os.remove('../input_csv_files/timezone_modified.csv')
        original_df = load_csv_to_df('../input_csv_files/timezone.csv')

        if not os.path.exists('../input_csv_files/timezone_modified.csv'):
            response = self.app.delete('/api/1.0/time-converter/0', )
            after_delete_df = load_csv_to_df('../input_csv_files/timezone_modified.csv')

            self.assertTrue(len(original_df), len(after_delete_df) + 1)
Ejemplo n.º 2
0
    def test_post_fail(self):
        ''' need to delete timezone_modified.csv first'''
        if os.path.exists('../input_csv_files/timezone_modified.csv'):
            os.remove('../input_csv_files/timezone_modified.csv')

        original_df = load_csv_to_df('../input_csv_files/timezone.csv')

        if not os.path.exists('../input_csv_files/timezone_modified.csv'):
            response = self.app.post(
                '/api/1.0/time-converter/add/?id=0&lat=-33.865143&lng=151.209900&timestamp=1480933800', )

            after_post_df = load_csv_to_df('../input_csv_files/timezone_modified.csv')

            self.assertTrue(len(original_df), len(after_post_df))
Ejemplo n.º 3
0
    def test_whole_csv_file_cases(self):
        from Utils.csv_file_parser import load_csv_to_df, add_converted_column_on_df

        df = load_csv_to_df()
        add_converted_column_on_df(df)

        target_result = ['16/04/2017 10:04 +10 +1000', '04/03/2003 07:45 +03 +0300', '07/07/2015 07:30 BST +0100',
                         '23/09/1998 22:48 +07 +0700', '11/03/2010 23:34 EAT +0300', '01/11/2013 06:05 GMT +0000',
                         '07/05/2007 21:51 SAST +0200', '25/08/2011 10:00 NZST +1200', '08/04/2016 06:12 AEST +1000',
                         '03/10/2012 18:27 CEST +0200', '02/06/2017 03:34 AEST +1000']

        for index, row in df.iterrows():
            self.assertEqual(row["local_time"], target_result[index])
Ejemplo n.º 4
0
from Utils.csv_file_parser import load_csv_to_df, add_converted_column_on_df, output_df_to_csv

if __name__ == '__main__':
    df = load_csv_to_df()
    df = add_converted_column_on_df(df)
    output_df_to_csv(df)

    print('successful output')