@@ -866,7 +866,7 @@ def test_uniqueness_foreign_id(self):
866
866
"verb" : "tweet" ,
867
867
"object" : 1 ,
868
868
"foreign_id" : "tweet:11" ,
869
- "time" : now ,
869
+ "time" : utcnow ,
870
870
}
871
871
self .user1 .add_activity (activity_data )
872
872
@@ -875,7 +875,7 @@ def test_uniqueness_foreign_id(self):
875
875
"verb" : "tweet" ,
876
876
"object" : 3 ,
877
877
"foreign_id" : "tweet:11" ,
878
- "time" : now ,
878
+ "time" : utcnow ,
879
879
}
880
880
self .user1 .add_activity (activity_data )
881
881
@@ -1125,3 +1125,67 @@ def test_get_activities_full(self):
1125
1125
response = self .c .get_activities (foreign_id_times = [(fid , dt )])
1126
1126
self .assertEqual (len (response ["results" ]), 1 )
1127
1127
self .assertEqual (activity ["foreign_id" ], response ["results" ][0 ]["foreign_id" ])
1128
+
1129
+ def test_activity_partial_update (self ):
1130
+ now = datetime .datetime .utcnow ()
1131
+ feed = self .c .feed ('user' , uuid4 ())
1132
+ feed .add_activity ({
1133
+ "actor" : "barry" ,
1134
+ "object" : "09" ,
1135
+ "verb" : "tweet" ,
1136
+ "time" : now ,
1137
+ "foreign_id" : 'fid:123' ,
1138
+ 'product' : {
1139
+ 'name' : 'shoes' ,
1140
+ 'price' : 9.99 ,
1141
+ 'color' : 'blue'
1142
+ }
1143
+ })
1144
+ activity = feed .get ()['results' ][0 ]
1145
+
1146
+ set = {
1147
+ 'product.name' : 'boots' ,
1148
+ 'product.price' : 7.99 ,
1149
+ 'popularity' : 1000 ,
1150
+ 'foo' : {
1151
+ 'bar' : {
1152
+ 'baz' : 'qux' ,
1153
+ }
1154
+ }
1155
+ }
1156
+ unset = [ 'product.color' ]
1157
+
1158
+ # partial update by ID
1159
+ self .c .activity_partial_update (id = activity ['id' ], set = set , unset = unset )
1160
+ updated = feed .get ()['results' ][0 ]
1161
+ expected = activity
1162
+ expected ['product' ] = {
1163
+ 'name' : 'boots' ,
1164
+ 'price' : 7.99
1165
+ }
1166
+ expected ['popularity' ] = 1000
1167
+ expected ['foo' ] = {
1168
+ 'bar' : {
1169
+ 'baz' : 'qux'
1170
+ }
1171
+ }
1172
+ self .assertEqual (updated , expected )
1173
+
1174
+ # partial update by foreign ID + time
1175
+ set = {
1176
+ 'foo.bar.baz' : 42 ,
1177
+ 'popularity' : 9000
1178
+ }
1179
+ unset = [ 'product.price' ]
1180
+ self .c .activity_partial_update (foreign_id = activity ['foreign_id' ], time = activity ['time' ], set = set , unset = unset )
1181
+ updated = feed .get ()['results' ][0 ]
1182
+ expected ['product' ] = {
1183
+ 'name' : 'boots'
1184
+ }
1185
+ expected ['foo' ] = {
1186
+ 'bar' : {
1187
+ 'baz' : 42
1188
+ }
1189
+ }
1190
+ expected ['popularity' ] = 9000
1191
+ self .assertEqual (updated , expected )
0 commit comments