@@ -49,13 +49,17 @@ def test_path_is_abstract(self):
49
49
def test_reload (self ):
50
50
connection = _Connection ({'foo' : 'Foo' })
51
51
derived = self ._derivedClass (connection , '/path' )()
52
+ # Make sure changes is not a set, so we can observe a change.
53
+ derived ._changes = object ()
52
54
derived .reload ()
53
55
self .assertEqual (derived ._properties , {'foo' : 'Foo' })
54
56
kw = connection ._requested
55
57
self .assertEqual (len (kw ), 1 )
56
58
self .assertEqual (kw [0 ]['method' ], 'GET' )
57
59
self .assertEqual (kw [0 ]['path' ], '/path' )
58
60
self .assertEqual (kw [0 ]['query_params' ], {'projection' : 'noAcl' })
61
+ # Make sure changes get reset by reload.
62
+ self .assertEqual (derived ._changes , set ())
59
63
60
64
def test__patch_properties (self ):
61
65
connection = _Connection ({'foo' : 'Foo' })
@@ -69,6 +73,26 @@ def test__patch_properties(self):
69
73
self .assertEqual (kw [0 ]['data' ], {'foo' : 'Foo' })
70
74
self .assertEqual (kw [0 ]['query_params' ], {'projection' : 'full' })
71
75
76
+ def test_patch (self ):
77
+ connection = _Connection ({'foo' : 'Foo' })
78
+ derived = self ._derivedClass (connection , '/path' )()
79
+ # Make sure changes is non-empty, so we can observe a change.
80
+ BAR = object ()
81
+ BAZ = object ()
82
+ derived ._properties = {'bar' : BAR , 'baz' : BAZ }
83
+ derived ._changes = set (['bar' ]) # Ignore baz.
84
+ derived .patch ()
85
+ self .assertEqual (derived ._properties , {'foo' : 'Foo' })
86
+ kw = connection ._requested
87
+ self .assertEqual (len (kw ), 1 )
88
+ self .assertEqual (kw [0 ]['method' ], 'PATCH' )
89
+ self .assertEqual (kw [0 ]['path' ], '/path' )
90
+ self .assertEqual (kw [0 ]['query_params' ], {'projection' : 'full' })
91
+ # Since changes does not include `baz`, we don't see it sent.
92
+ self .assertEqual (kw [0 ]['data' ], {'bar' : BAR })
93
+ # Make sure changes get reset by patch().
94
+ self .assertEqual (derived ._changes , set ())
95
+
72
96
73
97
class Test__scalar_property (unittest2 .TestCase ):
74
98
0 commit comments