def test_selected_value_to_singer_value_impl_with_timestamp_tz_value_as_datetime_expect_iso_format( self): output = logical_replication.selected_value_to_singer_value_impl( datetime(2020, 9, 1, 23, 10, 59, tzinfo=tzoffset(None, -3600)), 'timestamp with time zone', None) self.assertEqual('2020-09-01T23:10:59-01:00', output)
def test_selected_value_to_singer_value_impl_with_timestamp_tz_value_as_datetime_min( self): output = logical_replication.selected_value_to_singer_value_impl( datetime(1, 1, 1, 0, 0, 0, 123, tzinfo=tzoffset(None, 14400)), 'timestamp with time zone', None) self.assertEqual('9999-12-31T23:59:59.999+00:00', output)
def test_selected_value_to_singer_value_impl_with_timestamp_ntz_value_as_datetime_max( self): output = logical_replication.selected_value_to_singer_value_impl( datetime(9999, 12, 31, 23, 59, 59, 999999), 'timestamp without time zone', None) self.assertEqual('9999-12-31T23:59:59.999+00:00', output)
def test_selected_value_to_singer_value_impl_with_timestamp_ntz_value_as_datetime_min( self): output = logical_replication.selected_value_to_singer_value_impl( datetime(1, 1, 1, 0, 0, 0, 123), 'timestamp without time zone', None) self.assertEqual('0001-01-01T00:00:00.000123+00:00', output)
def test_selected_value_to_singer_value_impl_with_timestamp_ntz_value_as_datetime_expect_iso_format( self): output = logical_replication.selected_value_to_singer_value_impl( datetime(2020, 9, 1, 20, 10, 59), 'timestamp without time zone', None) self.assertEqual('2020-09-01T20:10:59+00:00', output)
def test_selected_value_to_singer_value_impl_with_timestamp_tz_value_as_string_AC( self): """ Test selected_value_to_singer_value_impl with timestamp with tz as string where era is AC should fallback to max datetime allowed """ output = logical_replication.selected_value_to_singer_value_impl( '1000-09-01 20:10:56-09 AC', 'timestamp with time zone', None) self.assertEqual('9999-12-31T23:59:59.999+00:00', output)
def test_selected_value_to_singer_value_impl_with_timestamp_ntz_value_as_string_out_of_range_2( self): """ Test selected_value_to_singer_value_impl with timestamp without tz as string where year is < 0001 should fallback to max datetime allowed """ output = logical_replication.selected_value_to_singer_value_impl( '0000-09-01 20:10:56', 'timestamp without time zone', None) self.assertEqual('9999-12-31T23:59:59.999+00:00', output)
def test_selected_value_to_singer_value_impl_with_non_empty_jsonb_returns_equivalent_dict( self): output = logical_replication.selected_value_to_singer_value_impl( '{"key1": "A", "key2": [{"kk": "yo"}, {}]}', 'jsonb', None) self.assertEqual({'key1': 'A', 'key2': [{'kk': 'yo'}, {}]}, output)
def test_selected_value_to_singer_value_impl_with_empty_jsonb_returns_empty_dict( self): output = logical_replication.selected_value_to_singer_value_impl( '{}', 'jsonb', None) self.assertEqual({}, output)
def test_selected_value_to_singer_value_impl_with_null_jsonb_returns_None( self): output = logical_replication.selected_value_to_singer_value_impl( None, 'jsonb', None) self.assertEqual(None, output)
def test_selected_value_to_singer_value_impl_with_timestamp_tz_value_as_string_max( self): output = logical_replication.selected_value_to_singer_value_impl( '9999-12-31 23:59:59.999999-03', 'timestamp with time zone', None) self.assertEqual('9999-12-31T23:59:59.999+00:00', output)
def test_selected_value_to_singer_value_impl_with_timestamp_tz_value_as_string_expect_iso_format( self): output = logical_replication.selected_value_to_singer_value_impl( '2020-09-01 20:10:56+05', 'timestamp with time zone', None) self.assertEqual('2020-09-01T20:10:56+05:00', output)