Exemplo n.º 1
0
 def test_getent(self):
     obj_group_mock = MagicMock(
         return_value=[
             MockGroupObj("salt", ["WinNT://HOST/steve"]),
             MockGroupObj("salty", ["WinNT://HOST/spongebob"]),
         ]
     )
     mock_g_to_g = MagicMock(side_effect=[1, 2])
     with patch.object(win_groupadd, "_get_all_groups", obj_group_mock), patch.dict(
         win_groupadd.__salt__, {"file.group_to_gid": mock_g_to_g}
     ):
         self.assertListEqual(
             win_groupadd.getent(),
             [
                 {
                     "gid": 1,
                     "members": ["HOST\\steve"],
                     "name": "salt",
                     "passwd": "x",
                 },
                 {
                     "gid": 2,
                     "members": ["HOST\\spongebob"],
                     "name": "salty",
                     "passwd": "x",
                 },
             ],
         )
Exemplo n.º 2
0
 def test_getent(self):
     groupobj_mock = MagicMock(return_value=[
         MockGroupObj('salt', ['WinNT://HOST/steve']),
         MockGroupObj('salty', ['WinNT://HOST/spongebob'])
     ])
     mock_g_to_g = MagicMock(side_effect=[1, 2])
     with patch.object(win_groupadd, '_get_all_groups', groupobj_mock),\
          patch.dict(win_groupadd.__salt__, {'file.group_to_gid': mock_g_to_g}):
         self.assertListEqual(win_groupadd.getent(),
                              [{
                                  'gid': 1,
                                  'members': ['HOST\\steve'],
                                  'name': 'salt',
                                  'passwd': 'x'
                              }, {
                                  'gid': 2,
                                  'members': ['HOST\\spongebob'],
                                  'name': 'salty',
                                  'passwd': 'x'
                              }])
Exemplo n.º 3
0
 def test_getent_context(self):
     '''
     Test group.getent is using the values in __context__
     '''
     with patch.dict(win_groupadd.__context__, {'group.getent': True}):
         self.assertTrue(win_groupadd.getent())
Exemplo n.º 4
0
 def test_getent_context(self):
     """
     Test group.getent is using the values in __context__
     """
     with patch.dict(win_groupadd.__context__, {"group.getent": True}):
         self.assertTrue(win_groupadd.getent())
Exemplo n.º 5
0
 def test_getent(self):
     '''
     Test if it return info on all groups
     '''
     with patch.dict(win_groupadd.__context__, {'group.getent': True}):
         self.assertTrue(win_groupadd.getent())
Exemplo n.º 6
0
 def test_getent(self):
     '''
     Test if it return info on all groups
     '''
     with patch.dict(win_groupadd.__context__, {'group.getent': True}):
         self.assertTrue(win_groupadd.getent())