Skip to content

Commit

Permalink
Fix: Update arrow to more recent version
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-krasontovitsch authored and ahmedsajid committed Dec 13, 2021
1 parent d7bbdaf commit 27d103d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bonfire/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def run(host,
if follow:
limit = None
sort = None
sr.from_time = arrow.now('local').replace(seconds=-latency - 1)
sr.to_time = arrow.now('local').replace(seconds=-latency)
sr.from_time = arrow.now('local').shift(seconds=-latency - 1)
sr.to_time = arrow.now('local').shift(seconds=-latency)

# Get the user permissions
userinfo = gl_api.user_info(username)
Expand Down
2 changes: 1 addition & 1 deletion bonfire/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run_logprint(api, query, formatter, follow=False, interval=0, latency=2, out
while True:
result = run_logprint(api, query, formatter, follow=False, output=output)
new_range = SearchRange(from_time=result.range_to,
to_time=arrow.now(api.host_tz).replace(seconds=-latency))
to_time=arrow.now(api.host_tz).shift(seconds=-latency))
query = query.copy_with_range(new_range)

time.sleep(interval / 1000.0)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ keyring>=9,<11
parsedatetime>=1.4,<3
python-dateutil>=2.4.1,<3
requests>=2.4.3,<3.0
arrow>=0.5.4,<0.12
arrow>=0.13.0,<0.16
termcolor==1.1.0
six>=1.9.0
20 changes: 13 additions & 7 deletions tests/test_dateutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ def test_datetime_parser():
now = arrow.now()

ts_tuples = [
("10 minutes ago", lambda x: x.replace(minutes=-10, microsecond=0, tzinfo='local')),
("1 day ago", lambda x: x.replace(days=-1, microsecond=0, tzinfo='local')),
("yesterday midnight", lambda x: x.replace(days=-1, hour=0, minute=0, second=0, microsecond=0, tzinfo='local')),
("1986-04-24 00:51:24+02:00", lambda x: arrow.get("1986-04-24 00:51:24+02:00")),
("2001-01-01 01:01:01", lambda x: arrow.get("2001-01-01 01:01:01").replace(tzinfo="local")),
("10 minutes ago", lambda x: x.shift(minutes=-10).\
replace(microsecond=0, tzinfo='local')),
("1 day ago", lambda x: x.shift(days=-1)\
.replace(microsecond=0, tzinfo='local')),
("yesterday midnight", lambda x: x.shift(days=-1).replace(hour=0,
minute=0, second=0, microsecond=0, tzinfo='local')),
("1986-04-24 00:51:24+02:00",
lambda x: arrow.get("1986-04-24 00:51:24+02:00")),
("2001-01-01 01:01:01",
lambda x: arrow.get("2001-01-01 01:01:01").replace(tzinfo="local")),
(now, lambda x: now)]

for (s, ts) in ts_tuples:
assert datetime_parser(s) == ts(arrow.now())
assert datetime_parser(s) == ts(now)

with pytest.raises(ValueError):
datetime_parser("fdjkldfhskl")
Expand All @@ -32,4 +37,5 @@ def test_datetime_converter():

assert datetime_converter(None) is None
assert datetime_converter(now) == now
assert datetime_converter("1 day ago") == arrow.now().replace(days=-1, microsecond=0, tzinfo='local')
assert datetime_converter("1 day ago") == arrow.now().shift(days=-1)\
.replace(microsecond=0, tzinfo='local')

0 comments on commit 27d103d

Please sign in to comment.