Skip to content

Commit d790bf7

Browse files
committed
Timestamps must be greater than 3600
On Windows, timestamps must (typically) be greater than 3600, otherwise they throw an `OSError` See dateutil/dateutil#197 (*arrow* depends on *dateutil*)
1 parent 7d96020 commit d790bf7

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
[
22
[
3-
0,
4-
15,
3+
4000,
4+
4015,
55
"foo",
66
"1",
77
[],
8-
15
8+
4015
99
],
1010
[
11-
20,
12-
50,
11+
4020,
12+
4050,
1313
"bar",
1414
"2",
1515
[],
16-
50
16+
4050
1717
],
1818
[
19-
50,
20-
100,
19+
4050,
20+
4100,
2121
"bar",
2222
"3",
2323
[],
24-
100
24+
4100
2525
]
2626
]

tests/test_watson.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import os
55
import sys
66

7+
import arrow
8+
from click import get_app_dir
79
import py
810
import pytest
911
import requests
10-
import arrow
1112

12-
from click import get_app_dir
1313
from watson import Watson, WatsonError
14-
from watson.watson import ConfigurationError, ConfigParser
1514

1615
from . import mock_read
16+
from watson.watson import ConfigParser, ConfigurationError
1717

1818

1919
PY2 = sys.version_info[0] == 2
@@ -32,11 +32,11 @@
3232
# current
3333

3434
def test_current(mock, watson):
35-
content = json.dumps({'project': 'foo', 'start': 0, 'tags': ['A', 'B']})
35+
content = json.dumps({'project': 'foo', 'start': 4000, 'tags': ['A', 'B']})
3636

3737
mock.patch('%s.open' % builtins, mock.mock_open(read_data=content))
3838
assert watson.current['project'] == 'foo'
39-
assert watson.current['start'] == arrow.get(0)
39+
assert watson.current['start'] == arrow.get(4000)
4040
assert watson.current['tags'] == ['A', 'B']
4141

4242

@@ -61,16 +61,16 @@ def test_current_watson_non_valid_json(mock, watson):
6161

6262

6363
def test_current_with_given_state(config_dir, mock):
64-
content = json.dumps({'project': 'foo', 'start': 0})
65-
watson = Watson(current={'project': 'bar', 'start': 0},
64+
content = json.dumps({'project': 'foo', 'start': 4000})
65+
watson = Watson(current={'project': 'bar', 'start': 4000},
6666
config_dir=config_dir)
6767

6868
mock.patch('%s.open' % builtins, mock.mock_open(read_data=content))
6969
assert watson.current['project'] == 'bar'
7070

7171

7272
def test_current_with_empty_given_state(config_dir, mock):
73-
content = json.dumps({'project': 'foo', 'start': 0})
73+
content = json.dumps({'project': 'foo', 'start': 4000})
7474
watson = Watson(current=[], config_dir=config_dir)
7575

7676
mock.patch('%s.open' % builtins, mock.mock_open(read_data=content))
@@ -80,7 +80,7 @@ def test_current_with_empty_given_state(config_dir, mock):
8080
# last_sync
8181

8282
def test_last_sync(mock, watson):
83-
now = arrow.get(123)
83+
now = arrow.get(4123)
8484
content = json.dumps(now.timestamp)
8585

8686
mock.patch('%s.open' % builtins, mock.mock_open(read_data=content))
@@ -127,24 +127,24 @@ def test_last_sync_with_empty_given_state(config_dir, mock):
127127
# frames
128128

129129
def test_frames(mock, watson):
130-
content = json.dumps([[0, 10, 'foo', None, ['A', 'B', 'C']]])
130+
content = json.dumps([[4000, 4010, 'foo', None, ['A', 'B', 'C']]])
131131

132132
mock.patch('%s.open' % builtins, mock.mock_open(read_data=content))
133133
assert len(watson.frames) == 1
134134
assert watson.frames[0].project == 'foo'
135-
assert watson.frames[0].start == arrow.get(0)
136-
assert watson.frames[0].stop == arrow.get(10)
135+
assert watson.frames[0].start == arrow.get(4000)
136+
assert watson.frames[0].stop == arrow.get(4010)
137137
assert watson.frames[0].tags == ['A', 'B', 'C']
138138

139139

140140
def test_frames_without_tags(mock, watson):
141-
content = json.dumps([[0, 10, 'foo', None]])
141+
content = json.dumps([[4000, 4010, 'foo', None]])
142142

143143
mock.patch('%s.open' % builtins, mock.mock_open(read_data=content))
144144
assert len(watson.frames) == 1
145145
assert watson.frames[0].project == 'foo'
146-
assert watson.frames[0].start == arrow.get(0)
147-
assert watson.frames[0].stop == arrow.get(10)
146+
assert watson.frames[0].start == arrow.get(4000)
147+
assert watson.frames[0].stop == arrow.get(4010)
148148
assert watson.frames[0].tags == []
149149

150150

@@ -169,8 +169,8 @@ def test_frames_watson_non_valid_json(mock, watson):
169169

170170

171171
def test_given_frames(config_dir, mock):
172-
content = json.dumps([[0, 10, 'foo', None, ['A']]])
173-
watson = Watson(frames=[[0, 10, 'bar', None, ['A', 'B']]],
172+
content = json.dumps([[4000, 4010, 'foo', None, ['A']]])
173+
watson = Watson(frames=[[4000, 4010, 'bar', None, ['A', 'B']]],
174174
config_dir=config_dir)
175175

176176
mock.patch('%s.open' % builtins, mock.mock_open(read_data=content))
@@ -353,7 +353,7 @@ def test_save_current_without_tags(mock, watson):
353353

354354

355355
def test_save_empty_current(config_dir, mock):
356-
watson = Watson(current={'project': 'foo', 'start': 0},
356+
watson = Watson(current={'project': 'foo', 'start': 4000},
357357
config_dir=config_dir)
358358
watson.current = {}
359359

@@ -367,7 +367,7 @@ def test_save_empty_current(config_dir, mock):
367367

368368

369369
def test_save_frames_no_change(config_dir, mock):
370-
watson = Watson(frames=[[0, 10, 'foo', None]],
370+
watson = Watson(frames=[[4000, 4010, 'foo', None]],
371371
config_dir=config_dir)
372372

373373
mock.patch('%s.open' % builtins, mock.mock_open())
@@ -378,8 +378,8 @@ def test_save_frames_no_change(config_dir, mock):
378378

379379

380380
def test_save_added_frame(config_dir, mock):
381-
watson = Watson(frames=[[0, 10, 'foo', None]], config_dir=config_dir)
382-
watson.frames.add('bar', 10, 20, ['A'])
381+
watson = Watson(frames=[[4000, 4010, 'foo', None]], config_dir=config_dir)
382+
watson.frames.add('bar', 4010, 4020, ['A'])
383383

384384
mock.patch('%s.open' % builtins, mock.mock_open())
385385
json_mock = mock.patch('json.dump')
@@ -395,9 +395,9 @@ def test_save_added_frame(config_dir, mock):
395395

396396

397397
def test_save_changed_frame(config_dir, mock):
398-
watson = Watson(frames=[[0, 10, 'foo', None, ['A']]],
398+
watson = Watson(frames=[[4000, 4010, 'foo', None, ['A']]],
399399
config_dir=config_dir)
400-
watson.frames[0] = ('bar', 0, 10, ['A', 'B'])
400+
watson.frames[0] = ('bar', 4000, 4010, ['A', 'B'])
401401

402402
mock.patch('%s.open' % builtins, mock.mock_open())
403403
json_mock = mock.patch('json.dump')
@@ -504,18 +504,18 @@ def test_push(mock, watson):
504504
config.set('backend', 'url', 'http://foo.com')
505505
config.set('backend', 'token', 'bar')
506506

507-
watson.frames.add('foo', 1, 2)
508-
watson.frames.add('foo', 3, 4)
507+
watson.frames.add('foo', 4001, 4002)
508+
watson.frames.add('foo', 4003, 4004)
509509

510510
watson.last_sync = arrow.now()
511511

512-
watson.frames.add('bar', 1, 2, ['A', 'B'])
513-
watson.frames.add('lol', 1, 2)
512+
watson.frames.add('bar', 4001, 4002, ['A', 'B'])
513+
watson.frames.add('lol', 4001, 4002)
514514

515515
last_pull = arrow.now()
516516

517-
watson.frames.add('foo', 1, 2)
518-
watson.frames.add('bar', 3, 4)
517+
watson.frames.add('foo', 4001, 4002)
518+
watson.frames.add('bar', 4003, 4004)
519519

520520
mock.patch.object(watson, '_get_remote_projects', return_value=[
521521
{'name': 'foo', 'id': '08288b71-4500-40dd-96b1-a995937a15fd'},
@@ -590,7 +590,7 @@ def test_pull(mock, watson):
590590
watson.last_sync = arrow.now()
591591

592592
watson.frames.add(
593-
'foo', 1, 2, ['A', 'B'], id='1c006c6e6cc14c80ab22b51c857c0b06'
593+
'foo', 4001, 4002, ['A', 'B'], id='1c006c6e6cc14c80ab22b51c857c0b06'
594594
)
595595

596596
mock.patch.object(watson, '_get_remote_projects', return_value=[
@@ -607,15 +607,15 @@ def json(self):
607607
{
608608
'id': '1c006c6e-6cc1-4c80-ab22-b51c857c0b06',
609609
'project': 'foo',
610-
'start_at': 3,
611-
'end_at': 4,
610+
'start_at': 4003,
611+
'end_at': 4004,
612612
'tags': ['A']
613613
},
614614
{
615615
'id': 'c44aa815-4d77-4a58-bddd-1afa95562141',
616616
'project': 'bar',
617-
'start_at': 4,
618-
'end_at': 5,
617+
'start_at': 4004,
618+
'end_at': 4005,
619619
'tags': []
620620
}
621621
]
@@ -638,22 +638,22 @@ def json(self):
638638

639639
assert watson.frames[0].id == '1c006c6e6cc14c80ab22b51c857c0b06'
640640
assert watson.frames[0].project == 'foo'
641-
assert watson.frames[0].start.timestamp == 3
642-
assert watson.frames[0].stop.timestamp == 4
641+
assert watson.frames[0].start.timestamp == 4003
642+
assert watson.frames[0].stop.timestamp == 4004
643643
assert watson.frames[0].tags == ['A']
644644

645645
assert watson.frames[1].id == 'c44aa8154d774a58bddd1afa95562141'
646646
assert watson.frames[1].project == 'bar'
647-
assert watson.frames[1].start.timestamp == 4
648-
assert watson.frames[1].stop.timestamp == 5
647+
assert watson.frames[1].start.timestamp == 4004
648+
assert watson.frames[1].stop.timestamp == 4005
649649
assert watson.frames[1].tags == []
650650

651651

652652
# projects
653653

654654
def test_projects(watson):
655655
for name in ('foo', 'bar', 'bar', 'bar', 'foo', 'lol'):
656-
watson.frames.add(name, 0, 0)
656+
watson.frames.add(name, 4000, 4000)
657657

658658
assert watson.projects == ['bar', 'foo', 'lol']
659659

@@ -674,7 +674,7 @@ def test_tags(watson):
674674
)
675675

676676
for name, tags in samples:
677-
watson.frames.add(name, 0, 0, tags)
677+
watson.frames.add(name, 4000, 4000, tags)
678678

679679
assert watson.tags == ['A', 'B', 'C', 'D']
680680

@@ -690,8 +690,8 @@ def test_tags_no_frames(watson):
690690
)
691691
def test_merge_report(watson, datafiles):
692692
# Get report
693-
watson.frames.add('foo', 0, 15, id='1', updated_at=15)
694-
watson.frames.add('bar', 20, 45, id='2', updated_at=45)
693+
watson.frames.add('foo', 4000, 4015, id='1', updated_at=4015)
694+
watson.frames.add('bar', 4020, 4045, id='2', updated_at=4045)
695695

696696
conflicting, merging = watson.merge_report(
697697
str(datafiles) + '/frames-with-conflict')

0 commit comments

Comments
 (0)