def test_commit(self): """ If we call a commit, it should first apply whatever changes are left (we hook into that instead of checking the effect) and then the commit on the updater should have been called. Then we check it raises value error for whatever operation we try. """ diff = Diff(self, Name('example.org.')) diff.add_data(self.__rrset1) orig_apply = diff.apply diff.apply = self.__mock_apply diff.commit() self.assertTrue(self.__apply_called) self.assertTrue(self.__commit_called) # The data should be handled by apply which we replaced. self.assertEqual([], self.__data_operations) # Now check all range of other methods raise ValueError self.assertRaises(ValueError, diff.commit) self.assertRaises(ValueError, diff.add_data, self.__rrset2) self.assertRaises(ValueError, diff.delete_data, self.__rrset1) self.assertRaises(ValueError, diff.find, Name('foo.example.org.'), RRType.A()) self.assertRaises(ValueError, diff.find_all, Name('foo.example.org.')) diff.apply = orig_apply self.assertRaises(ValueError, diff.apply) # This one does not state it should raise, so check it doesn't # But it is NOP in this situation anyway diff.compact()