testcase: for datetime format completion
@@ -124,3 +124,62 @@ def test_timestamp_completer_humanize_time_completion(fake_now):
display_meta="30 seconds ago (2020-01-08 12:36:23)",
),
]
+
+ # No plural
+ fake_document.text = fake_document.text_before_cursor = "1"
+ completions = list(c.get_completions(fake_document, None))
+
+ assert completions == [
+ Completion(
+ text="1546951013000",
+ start_position=-1,
+ display=FormattedText([("", "1546951013000")]),
+ display_meta="1 year ago (2019-01-08 12:36:53)",
+ ),
+ Completion(
+ text="1575808613000",
+ start_position=-1,
+ display=FormattedText([("", "1575808613000")]),
+ display_meta="1 month ago (2019-12-08 12:36:53)",
+ ),
+ Completion(
+ text="1578400613000",
+ start_position=-1,
+ display=FormattedText([("", "1578400613000")]),
+ display_meta="1 day ago (2020-01-07 12:36:53)",
+ ),
+ Completion(
+ text="1578483413000",
+ start_position=-1,
+ display=FormattedText([("", "1578483413000")]),
+ display_meta="1 hour ago (2020-01-08 11:36:53)",
+ ),
+ Completion(
+ text="1578486953000",
+ start_position=-1,
+ display=FormattedText([("", "1578486953000")]),
+ display_meta="1 minute ago (2020-01-08 12:35:53)",
+ ),
+ Completion(
+ text="1578487012000",
+ start_position=-1,
+ display=FormattedText([("", "1578487012000")]),
+ display_meta="1 second ago (2020-01-08 12:36:52)",
+ ),
+ ]
+
+
+def test_timestamp_completer_datetime_format_time_completion():
+ c = TimestampCompleter()
+ fake_document = MagicMock()
+ fake_document.text = fake_document.text_before_cursor = "2020-02-07"
+ completions = list(c.get_completions(fake_document, None))
+
+ assert completions == [
+ Completion(
+ text="1581033600000",
+ start_position=-10,
+ display=FormattedText([("", "1581033600000")]),
+ display_meta="2020-02-07T00:00:00+00:00",
+ )
+ ]
