1414#
1515
1616import mock
17+ from mock import call
1718
1819from osc_lib import exceptions
1920from osc_lib import utils
@@ -763,8 +764,6 @@ def setUp(self):
763764
764765 def test_project_show (self ):
765766
766- self .projects_mock .get .side_effect = [Exception ("Not found" ),
767- self .project ]
768767 self .projects_mock .get .return_value = self .project
769768
770769 arglist = [
@@ -790,11 +789,7 @@ def test_project_show(self):
790789 # data to be shown.
791790 columns , data = self .cmd .take_action (parsed_args )
792791
793- self .projects_mock .get .assert_called_with (
794- self .project .id ,
795- parents_as_list = False ,
796- subtree_as_list = False ,
797- )
792+ self .projects_mock .get .assert_called_once_with (self .project .id )
798793
799794 collist = (
800795 'description' ,
@@ -824,8 +819,6 @@ def test_project_show_parents(self):
824819 'parents' : [{'project' : {'id' : self .project .parent_id }}]
825820 }
826821 )
827- self .projects_mock .get .side_effect = [Exception ("Not found" ),
828- self .project ]
829822 self .projects_mock .get .return_value = self .project
830823
831824 arglist = [
@@ -849,11 +842,12 @@ def test_project_show_parents(self):
849842 }
850843
851844 columns , data = self .cmd .take_action (parsed_args )
852- self .projects_mock .get .assert_called_with (
853- self .project .id ,
854- parents_as_list = True ,
855- subtree_as_list = False ,
856- )
845+
846+ self .projects_mock .get .assert_has_calls ([call (self .project .id ),
847+ call (self .project .id ,
848+ parents_as_list = True ,
849+ subtree_as_list = False ,
850+ )])
857851
858852 collist = (
859853 'description' ,
@@ -885,8 +879,6 @@ def test_project_show_subtree(self):
885879 'subtree' : [{'project' : {'id' : 'children-id' }}]
886880 }
887881 )
888- self .projects_mock .get .side_effect = [Exception ("Not found" ),
889- self .project ]
890882 self .projects_mock .get .return_value = self .project
891883
892884 arglist = [
@@ -910,11 +902,11 @@ def test_project_show_subtree(self):
910902 }
911903
912904 columns , data = self .cmd .take_action (parsed_args )
913- self .projects_mock .get .assert_called_with (
914- self .project .id ,
915- parents_as_list = False ,
916- subtree_as_list = True ,
917- )
905+ self .projects_mock .get .assert_has_calls ([ call ( self . project . id ),
906+ call ( self .project .id ,
907+ parents_as_list = False ,
908+ subtree_as_list = True ,
909+ )] )
918910
919911 collist = (
920912 'description' ,
@@ -947,8 +939,6 @@ def test_project_show_parents_and_children(self):
947939 'subtree' : [{'project' : {'id' : 'children-id' }}]
948940 }
949941 )
950- self .projects_mock .get .side_effect = [Exception ("Not found" ),
951- self .project ]
952942 self .projects_mock .get .return_value = self .project
953943
954944 arglist = [
@@ -973,11 +963,11 @@ def test_project_show_parents_and_children(self):
973963 }
974964
975965 columns , data = self .cmd .take_action (parsed_args )
976- self .projects_mock .get .assert_called_with (
977- self .project .id ,
978- parents_as_list = True ,
979- subtree_as_list = True ,
980- )
966+ self .projects_mock .get .assert_has_calls ([ call ( self . project . id ),
967+ call ( self .project .id ,
968+ parents_as_list = True ,
969+ subtree_as_list = True ,
970+ )] )
981971
982972 collist = (
983973 'description' ,
0 commit comments