def test_add(self): ''' Test if it add the specified group ''' self.assertDictEqual(win_groupadd.add('foo'), {'changes': [], 'name': 'foo', 'result': None, 'comment': 'The group foo already exists.'})
def test_add(self): ''' Test adding a new group ''' info = MagicMock(return_value=False) with patch.object(win_groupadd, 'info', info),\ patch.object(win_groupadd, '_get_computer_object', Mock()): self.assertTrue(win_groupadd.add('foo'))
def test_add(self): """ Test adding a new group """ info = MagicMock(return_value=False) with patch.object(win_groupadd, "info", info), patch.object( win_groupadd, "_get_computer_object", Mock() ): self.assertTrue(win_groupadd.add("foo"))
def test_add_error(self): ''' Test adding a group and encountering an error ''' class CompObj(object): def Create(self, type, name): raise PYWINTYPES_ERROR obj_comp_mock = MagicMock(return_value=CompObj()) info = MagicMock(return_value=False) with patch.object(win_groupadd, 'info', info),\ patch.object(win_groupadd, '_get_computer_object', obj_comp_mock): self.assertFalse(win_groupadd.add('foo'))
def test_add(self): ''' Test adding a new group ''' info = MagicMock(return_value=False) with patch.object(win_groupadd, 'info', info),\ patch.object(win_groupadd, '_get_computer_object', Mock()): self.assertDictEqual( win_groupadd.add('foo'), { 'changes': ['Successfully created group foo'], 'name': 'foo', 'result': True, 'comment': '' })
def test_add_group_exists(self): ''' Test adding a new group if the group already exists ''' info = MagicMock( return_value={ 'name': 'foo', 'passwd': None, 'gid': None, 'members': ['HOST\\spongebob'] }) with patch.object(win_groupadd, 'info', info),\ patch.object(win_groupadd, '_get_computer_object', Mock()): self.assertFalse(win_groupadd.add('foo'))
def test_add_error(self): """ Test adding a group and encountering an error """ class CompObj: def Create(self, type, name): raise PYWINTYPES_ERROR obj_comp_mock = MagicMock(return_value=CompObj()) info = MagicMock(return_value=False) with patch.object(win_groupadd, "info", info), patch.object( win_groupadd, "_get_computer_object", obj_comp_mock ): self.assertFalse(win_groupadd.add("foo"))
def test_add_group_exists(self): """ Test adding a new group if the group already exists """ info = MagicMock( return_value={ "name": "foo", "passwd": None, "gid": None, "members": ["HOST\\spongebob"], }) with patch.object(win_groupadd, "info", info), patch.object(win_groupadd, "_get_computer_object", Mock()): self.assertFalse(win_groupadd.add("foo"))
def test_add_group_exists(self): ''' Test adding a new group if the group already exists ''' info = MagicMock( return_value={ 'name': 'foo', 'passwd': None, 'gid': None, 'members': ['HOST\\spongebob'] }) with patch.object(win_groupadd, 'info', info),\ patch.object(win_groupadd, '_get_computer_object', Mock()): self.assertDictEqual( win_groupadd.add('foo'), { 'changes': [], 'name': 'foo', 'result': None, 'comment': 'The group foo already exists.' })
def test_add_error(self): ''' Test adding a group and encountering an error ''' class CompObj(object): def Create(self, type, name): raise PYWINTYPES_ERROR compobj_mock = MagicMock(return_value=CompObj()) info = MagicMock(return_value=False) with patch.object(win_groupadd, 'info', info),\ patch.object(win_groupadd, '_get_computer_object', compobj_mock): self.assertDictEqual( win_groupadd.add('foo'), { 'changes': [], 'name': 'foo', 'result': False, 'comment': 'Failed to create group foo. C' })