@@ -278,6 +278,38 @@ def test_tag_object(self, mock_post):
278278 json = {"tags" : ["tag1" ], "ids" : ["1" ]},
279279 )
280280
281+ @patch ("yeti.api.requests.Session.post" )
282+ def test_new_tag (self , mock_post ):
283+ mock_response = MagicMock ()
284+ mock_response .content = b'{"name": "testtag"}'
285+ mock_post .return_value = mock_response
286+
287+ result = self .api .new_tag ("testtag" )
288+ self .assertEqual (result , {"name" : "testtag" })
289+ mock_post .assert_called_with (
290+ "http://fake-url/api/v2/tags/" ,
291+ json = {"name" : "testtag" },
292+ )
293+
294+ result = self .api .new_tag ("wdesc" , description = "desc" )
295+ mock_post .assert_called_with (
296+ "http://fake-url/api/v2/tags/" ,
297+ json = {"name" : "wdesc" , "description" : "desc" },
298+ )
299+
300+ @patch ("yeti.api.requests.Session.post" )
301+ def test_search_tags (self , mock_post ):
302+ mock_response = MagicMock ()
303+ mock_response .content = b'{"tags": [{"name": "tag1"}]}'
304+ mock_post .return_value = mock_response
305+
306+ result = self .api .search_tags ("tag1" )
307+ self .assertEqual (result , [{"name" : "tag1" }])
308+ mock_post .assert_called_with (
309+ "http://fake-url/api/v2/tags/search" ,
310+ json = {"name" : "tag1" , "count" : 100 , "page" : 0 },
311+ )
312+
281313 @patch ("yeti.api.requests.Session.post" )
282314 def test_link_objects (self , mock_post ):
283315 mock_response = MagicMock ()
0 commit comments