[svn] commit: r1840 - /branches/trac184/src/lib/python/isc/config/tests/cfgmgr_test.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon May 17 22:28:49 UTC 2010
Author: jinmei
Date: Mon May 17 22:28:48 2010
New Revision: 1840
Log:
added a couple of minor test cases.
Modified:
branches/trac184/src/lib/python/isc/config/tests/cfgmgr_test.py
Modified: branches/trac184/src/lib/python/isc/config/tests/cfgmgr_test.py
==============================================================================
--- branches/trac184/src/lib/python/isc/config/tests/cfgmgr_test.py (original)
+++ branches/trac184/src/lib/python/isc/config/tests/cfgmgr_test.py Mon May 17 22:28:48 2010
@@ -58,6 +58,34 @@
self.config_manager_data.write_to_file(output_file_name)
new_config = ConfigManagerData(self.data_path, output_file_name)
self.assertEqual(self.config_manager_data, new_config)
+
+ def test_write_to_nonwritable_file(self):
+ # test for config dump to a file under non existent directory.
+ # this should internally raise OSError and will fail with a log
+ # message.
+ # for better testability it should probably return an error code
+ # or re-raise a custom exception?
+ output_file_name = "notexist/b10-config-write-test";
+ self.config_manager_data.write_to_file(output_file_name)
+ # temporary file should be cleaned up, which is currently not the case
+ #tmpfile = self.config_manager_data.db_filename + ".tmp"
+ #self.assertEqual(os.path.exists(tmpfile), False)
+
+ def test_write_to_file_with_nonwritable_tmpfile(self):
+ # this test creates a temporary file without any permission
+ # that the config manager would create. The write attempt will fail
+ # with a log message.
+ # Note: it's probably better to use a unique temporary file using the
+ # tmpfile module. If we do so this test won't work.
+ tmpfile = self.config_manager_data.db_filename + ".tmp"
+ if os.path.exists(tmpfile):
+ os.remove(tmpfile)
+ f = open(tmpfile, 'w')
+ os.chmod(tmpfile, 0)
+ f.close()
+ output_file_name = "b10-config-write-test";
+ self.config_manager_data.write_to_file(output_file_name)
+ os.remove(tmpfile)
def test_equality(self):
# tests the __eq__ function. Equality is only defined
More information about the bind10-changes
mailing list