@@ -47,9 +47,13 @@ def tearDown(self):
47
47
self .cur .close ()
48
48
self .cnx .close ()
49
49
50
- def test_fill_is_latest_issue (self ):
50
+ def _test_fill_is_latest_issue (self , clbp , use_filter ):
51
51
"""Update rows having a stale `direction` field and serve the results."""
52
52
53
+ # NOTE: column order is:
54
+ # (id, source, signal, time_type, geo_type, time_value, geo_value,
55
+ # value_updated_timestamp, value, stderr, sample_size, direction_updated_timestamp, direction, issue, lag, is_latest_issue, is_wip)
56
+
53
57
self .cur .execute ('''
54
58
insert into covidcast values
55
59
(0, 'src', 'sig', 'day', 'state', 20200228, 'ca',
@@ -65,12 +69,35 @@ def test_fill_is_latest_issue(self):
65
69
(0, 'src', 'sig', 'day', 'state', 20200301, 'ca',
66
70
123, 5, 5, 5, 5, NULL, 20200302, 1, 1, False),
67
71
(0, 'src', 'sig', 'day', 'state', 20200301, 'ca',
72
+ 123, 5, 9, 8, 7, NULL, 20200301, 0, 1, False),
73
+ (0, 'src', 'sig', 'day', 'state', 20200228, 'ny',
74
+ 123, 2, 5, 5, 5, NULL, 20200228, 0, 1, False),
75
+ (0, 'src', 'sig', 'day', 'state', 20200228, 'ny',
76
+ 123, 2, 0, 0, 0, NULL, 20200229, 1, 1, False),
77
+ (0, 'src', 'sig', 'day', 'state', 20200229, 'ny',
78
+ 123, 6, 0, 0, 0, NULL, 20200301, 1, 1, False),
79
+ (0, 'src', 'sig', 'day', 'state', 20200229, 'ny',
80
+ 123, 6, 9, 9, 9, NULL, 20200229, 0, 1, False),
81
+ (0, 'src', 'sig', 'day', 'state', 20200301, 'ny',
82
+ 123, 5, 0, 0, 0, NULL, 20200303, 2, 1, False),
83
+ (0, 'src', 'sig', 'day', 'state', 20200301, 'ny',
84
+ 123, 5, 5, 5, 5, NULL, 20200302, 1, 1, False),
85
+ (0, 'src', 'sig', 'day', 'state', 20200301, 'ny',
68
86
123, 5, 9, 8, 7, NULL, 20200301, 0, 1, False)
69
87
''' )
70
88
self .cnx .commit ()
71
89
90
+ # NOTE: 'ny' values are identical to the 'ca' values, but with the `geo_value` changed
91
+
92
+ if use_filter :
93
+ # ignores ny
94
+ fc = "`geo_value` = 'ca'"
95
+ else :
96
+ # wildcard ; does not filter
97
+ fc = "TRUE"
98
+
72
99
# fill is_latest_issue
73
- main ()
100
+ main (FILTER_CONDITION = fc , CLEAR_LATEST_BY_PARTITION = clbp )
74
101
75
102
self .cur .execute ('''select * from covidcast''' )
76
103
result = list (self .cur )
@@ -88,7 +115,40 @@ def test_fill_is_latest_issue(self):
88
115
(6 , 'src' , 'sig' , 'day' , 'state' , 20200301 , 'ca' ,
89
116
123 , 5 , 5 , 5 , 5 , None , 20200302 , 1 , bytearray (b'0' ), bytearray (b'0' )),
90
117
(7 , 'src' , 'sig' , 'day' , 'state' , 20200301 , 'ca' ,
118
+ 123 , 5 , 9 , 8 , 7 , None , 20200301 , 0 , bytearray (b'0' ), bytearray (b'0' )),
119
+ (8 , 'src' , 'sig' , 'day' , 'state' , 20200228 , 'ny' ,
120
+ 123 , 2 , 5 , 5 , 5 , None , 20200228 , 0 , bytearray (b'0' ), bytearray (b'0' )),
121
+ (9 , 'src' , 'sig' , 'day' , 'state' , 20200228 , 'ny' ,
122
+ 123 , 2 , 0 , 0 , 0 , None , 20200229 , 1 , bytearray (b'1' ), bytearray (b'0' )),
123
+ (10 , 'src' , 'sig' , 'day' , 'state' , 20200229 , 'ny' ,
124
+ 123 , 6 , 0 , 0 , 0 , None , 20200301 , 1 , bytearray (b'1' ), bytearray (b'0' )),
125
+ (11 , 'src' , 'sig' , 'day' , 'state' , 20200229 , 'ny' ,
126
+ 123 , 6 , 9 , 9 , 9 , None , 20200229 , 0 , bytearray (b'0' ), bytearray (b'0' )),
127
+ (12 , 'src' , 'sig' , 'day' , 'state' , 20200301 , 'ny' ,
128
+ 123 , 5 , 0 , 0 , 0 , None , 20200303 , 2 , bytearray (b'1' ), bytearray (b'0' )),
129
+ (13 , 'src' , 'sig' , 'day' , 'state' , 20200301 , 'ny' ,
130
+ 123 , 5 , 5 , 5 , 5 , None , 20200302 , 1 , bytearray (b'0' ), bytearray (b'0' )),
131
+ (14 , 'src' , 'sig' , 'day' , 'state' , 20200301 , 'ny' ,
91
132
123 , 5 , 9 , 8 , 7 , None , 20200301 , 0 , bytearray (b'0' ), bytearray (b'0' ))
92
133
]
93
134
135
+ if use_filter :
136
+ # revert ny is_latest values
137
+ for i in range (7 , 14 ):
138
+ x = list (expected [i ])
139
+ x [- 2 ] = bytearray (b'1' )
140
+ expected [i ] = tuple (x )
141
+
94
142
self .assertEqual (result , expected )
143
+
144
+ def test_fill_is_latest_issue_by_partition (self ):
145
+ self ._test_fill_is_latest_issue (True , False )
146
+
147
+ def test_fill_is_latest_issue_not_by_partition (self ):
148
+ self ._test_fill_is_latest_issue (False , False )
149
+
150
+ def test_fill_is_latest_issue_by_partition_w_filter (self ):
151
+ self ._test_fill_is_latest_issue (True , True )
152
+
153
+ def test_fill_is_latest_issue_not_by_partition_w_filter (self ):
154
+ self ._test_fill_is_latest_issue (False , True )
0 commit comments