@@ -434,3 +434,89 @@ def resp_cont(url, request):
434434 self .assertIsInstance (obj , FakeObject )
435435 self .assertEqual (obj .key , 'foo' )
436436 self .assertEqual (obj .value , 'bar' )
437+
438+
439+ class TestExceptions (unittest .TestCase ):
440+ def setUp (self ):
441+ self .gl = Gitlab ("http://localhost" , private_token = "private_token" ,
442+ api_version = 4 )
443+
444+ def test_get_mixin (self ):
445+ class M (GetMixin , FakeManager ):
446+ pass
447+
448+ m = M (self .gl )
449+ self .assertRaises (GitlabGetError , m .get , 1 )
450+
451+ def test_get_without_id_mixin (self ):
452+ class M (GetWithoutIdMixin , FakeManager ):
453+ pass
454+
455+ m = M (self .gl )
456+ self .assertRaises (GitlabGetError , m .get )
457+
458+ def test_list_mixin (self ):
459+ class M (ListMixin , FakeManager ):
460+ pass
461+
462+ m = M (self .gl )
463+ self .assertRaises (GitlabListError , m .list )
464+
465+ def test_get_from_list_mixin (self ):
466+ class M (GetFromListMixin , FakeManager ):
467+ pass
468+
469+ m = M (self .gl )
470+ self .assertRaises (GitlabListError , m .list )
471+ self .assertRaises (GitlabGetError , m .get , 1 )
472+
473+ def test_create_mixin (self ):
474+ class M (CreateMixin , FakeManager ):
475+ pass
476+
477+ m = M (self .gl )
478+ self .assertRaises (GitlabCreateError , m .create , {})
479+
480+ def test_update_mixin (self ):
481+ class M (UpdateMixin , FakeManager ):
482+ pass
483+
484+ m = M (self .gl )
485+ self .assertRaises (GitlabUpdateError , m .update , 1 , {})
486+
487+ def test_set_mixin (self ):
488+ class M (SetMixin , FakeManager ):
489+ pass
490+
491+ m = M (self .gl )
492+ self .assertRaises (GitlabSetError , m .set , 'foo' , 'bar' )
493+
494+ def test_delete_mixin (self ):
495+ class M (DeleteMixin , FakeManager ):
496+ pass
497+
498+ m = M (self .gl )
499+ self .assertRaises (GitlabDeleteError , m .delete , 1 )
500+
501+ def test_object_mixin (self ):
502+ class M (UpdateMixin , DeleteMixin , FakeManager ):
503+ pass
504+
505+ class O (SaveMixin , ObjectDeleteMixin , AccessRequestMixin ,
506+ SubscribableMixin , TodoMixin , TimeTrackingMixin , RESTObject ):
507+ pass
508+
509+ mgr = M (self .gl )
510+ obj = O (mgr , {'id' : 42 , 'foo' : 'bar' })
511+ obj .foo = 'baz'
512+ self .assertRaises (GitlabUpdateError , obj .save )
513+ self .assertRaises (GitlabDeleteError , obj .delete )
514+ self .assertRaises (GitlabUpdateError , obj .approve )
515+ self .assertRaises (GitlabSubscribeError , obj .subscribe )
516+ self .assertRaises (GitlabUnsubscribeError , obj .unsubscribe )
517+ self .assertRaises (GitlabTodoError , obj .todo )
518+ self .assertRaises (GitlabTimeTrackingError , obj .time_stats )
519+ self .assertRaises (GitlabTimeTrackingError , obj .time_estimate , '1d' )
520+ self .assertRaises (GitlabTimeTrackingError , obj .reset_time_estimate )
521+ self .assertRaises (GitlabTimeTrackingError , obj .add_spent_time , '1d' )
522+ self .assertRaises (GitlabTimeTrackingError , obj .reset_spent_time )
0 commit comments