def test_doc_id_managed_on_initialize(self, _1, _2, module, *args):
   #old_rs_config provided by init_replset_mock via mrs.get_replset().
   #That returns None on the first call, so it falls through to get_rs_config_id(),
   #which is also mocked.
   mrs.update_replset(deepcopy(rs_config))
   new_id = module.exit_json.call_args[1]['config']['_id']
   self.assertEqual(rs_id, new_id)
 def test_doc_id_managed_on_initialize(self, _1, _2, module, *args):
     #old_rs_config provided by init_replset_mock via mrs.get_replset().
     #That returns None on the first call, so it falls through to get_rs_config_id(),
     #which is also mocked.
     mrs.update_replset(deepcopy(rs_config))
     new_id = module.exit_json.call_args[1]['config']['_id']
     self.assertEqual(rs_id, new_id)
    def test_not_changed_when_docs_match(self, _1, _2, module, *args):
        rs_config = {
            'members': members
        }  #This way the docs "match", but aren't identical

        mrs.update_replset(deepcopy(rs_config))
        changed = module.exit_json.call_args[1]['changed']
        self.assertFalse(changed)
 def test_ignores_magic_given_full_doc(self, _1, _2, module, _3,
                                       get_rs_config_id, *args):
     mrs.update_replset(deepcopy(new_rs_config))
     new_doc = module.exit_json.call_args[1]['config']
     self.assertEqual(new_doc, new_rs_config)
     self.assertFalse(get_rs_config_id.called)
 def test_reconfig_if_necessary(self, reconfig_replset, _2, module, *args):
     mrs.update_replset(deepcopy(rs_config))
     self.assertTrue(reconfig_replset.called)
 def test_initialize_if_necessary(self, initialize_replset, _2, module,
                                  *args):
     mrs.update_replset(deepcopy(rs_config))
     self.assertTrue(initialize_replset.called)
 def test_doc_id_managed_on_update(self, _1, _2, module, *args):
     #old_rs_config provided by update_replset_mock via mrs.get_replset()
     mrs.update_replset(deepcopy(rs_config))
     new_id = module.exit_json.call_args[1]['config']['_id']
     self.assertEqual(rs_id, new_id)
 def test_version_managed(self, _1, _2, module, *args):
     # Version set automatically on initialize
     mrs.update_replset(deepcopy(rs_config))
     new_version = module.exit_json.call_args[1]['config']['version']
     self.assertEqual(old_rs_config['version'], new_version - 1)
 def test_ignores_magic_given_full_doc(self, _1, _2, module, _3, get_rs_config_id, *args):
   mrs.update_replset(deepcopy(new_rs_config))
   new_doc = module.exit_json.call_args[1]['config']
   self.assertEqual(new_doc, new_rs_config)
   self.assertFalse(get_rs_config_id.called)
  def test_not_changed_when_docs_match(self, _1, _2, module, *args):
    rs_config = {'members': members}  #This way the docs "match", but aren't identical

    mrs.update_replset(deepcopy(rs_config))
    changed = module.exit_json.call_args[1]['changed']
    self.assertFalse(changed)
 def test_reconfig_if_necessary(self, reconfig_replset, _2, module, *args):
   mrs.update_replset(deepcopy(rs_config))
   self.assertTrue(reconfig_replset.called)
 def test_initialize_if_necessary(self, initialize_replset, _2, module, *args):
   mrs.update_replset(deepcopy(rs_config))
   self.assertTrue(initialize_replset.called)
 def test_doc_id_managed_on_update(self, _1, _2, module, *args):
   #old_rs_config provided by update_replset_mock via mrs.get_replset()
   mrs.update_replset(deepcopy(rs_config))
   new_id = module.exit_json.call_args[1]['config']['_id']
   self.assertEqual(rs_id, new_id)
 def test_version_managed(self, _1, _2, module, *args):
   # Version set automatically on initialize
   mrs.update_replset(deepcopy(rs_config))
   new_version = module.exit_json.call_args[1]['config']['version']
   self.assertEqual(old_rs_config['version'], new_version - 1)