@@ -171,6 +171,69 @@ def test_asset_requires_a_positive_id(self):
171
171
172
172
assert self .session .get .called is False
173
173
174
+ def test_create_ref (self ):
175
+ """Verify the request to create a reference."""
176
+ self .instance .create_ref ('refs/heads/foo' , 'my-fake-sha' )
177
+
178
+ self .post_called_with (
179
+ url_for ('git/refs' ),
180
+ data = {
181
+ 'ref' : 'refs/heads/foo' ,
182
+ 'sha' : 'my-fake-sha' ,
183
+ },
184
+ )
185
+
186
+ def test_create_ref_requires_a_reference_with_two_slashes (self ):
187
+ """Test that we check the validity of a reference."""
188
+ self .instance .create_ref ('refs/heads' , 'my-fake-sha' )
189
+
190
+ assert self .session .post .called is False
191
+
192
+ def test_create_ref_requires_a_reference_start_with_refs (self ):
193
+ """Test that we check the validity of a reference."""
194
+ self .instance .create_ref ('my-silly-ref/foo/bar' , 'my-fake-sha' )
195
+
196
+ assert self .session .post .called is False
197
+
198
+ def test_create_ref_requires_a_non_None_sha (self ):
199
+ """Test that we don't send an empty SHA."""
200
+ self .instance .create_ref ('refs/heads/valid' , None )
201
+
202
+ assert self .session .post .called is False
203
+
204
+ def test_create_ref_requires_a_truthy_sha (self ):
205
+ """Test that we don't send an empty SHA."""
206
+ self .instance .create_ref ('refs/heads/valid' , '' )
207
+
208
+ assert self .session .post .called is False
209
+
210
+ def test_create_tag_that_is_not_lightweight (self ):
211
+ """Verify we can create an annotated tag."""
212
+ self .instance .create_tag (
213
+ tag = 'tag-name' ,
214
+ message = 'message' ,
215
+ sha = 'my-sha' ,
216
+ obj_type = 'commit' ,
217
+ tagger = {'name' : 'Ian Cordasco' ,
218
+ 'email' : 'example@example.com' ,
219
+ 'date' : '2015-11-01T12:16:00Z' },
220
+ )
221
+
222
+ self .post_called_with (
223
+ url_for ('git/tags' ),
224
+ data = {
225
+ 'tag' : 'tag-name' ,
226
+ 'message' : 'message' ,
227
+ 'object' : 'my-sha' ,
228
+ 'type' : 'commit' ,
229
+ 'tagger' : {
230
+ 'name' : 'Ian Cordasco' ,
231
+ 'email' : 'example@example.com' ,
232
+ 'date' : '2015-11-01T12:16:00Z' ,
233
+ },
234
+ },
235
+ )
236
+
174
237
def test_create_tree (self ):
175
238
"""Verify the request to create a tree."""
176
239
self .instance .create_tree ([{'foo' : 'bar' }])
@@ -697,6 +760,11 @@ def test_add_collaborator(self):
697
760
with pytest .raises (GitHubError ):
698
761
self .instance .add_collaborator ('foo' )
699
762
763
+ def test_create_ref (self ):
764
+ """Verify that creating a tag requires authentication."""
765
+ with pytest .raises (GitHubError ):
766
+ self .instance .create_ref ('some ref' , 'some sha' )
767
+
700
768
def test_hooks (self ):
701
769
"""Show that a user must be authenticated to list hooks."""
702
770
with pytest .raises (GitHubError ):
0 commit comments