Commits

Arne Babenhauserheide  committed 51bf76b

added more tests for basic io.

  • Participants
  • Parent commits d7efd25

Comments (0)

Files changed (2)

                      states_dir="states"):
     """Get the data for one site.
 
-    >>> _test_clean_dirs()
+    >>> io._test_clean_dirs()
     >>> gpl = {'path': 'KSK@gpl.txt', 'description': 'The GNU General Public License. The most widespread license for free software.'}
     >>> put_data_for_key("KSK@gpl.txt", site=gpl, sites_dir="test_sites", states_dir="test_states")
     >>> gpl == get_data_for_key("KSK@gpl.txt", sites_dir="test_sites", states_dir="test_states")[0]
                      states_dir="states"):
     """Put a site or state or both into the site.
 
-    >>> _test_clean_dirs()
+    >>> io._test_clean_dirs()
     >>> gpl = {'path': 'KSK@gpl.txt', 'description': 'The GNU General Public License. The most widespread license for free software.'}
     >>> put_data_for_key("KSK@gpl.txt", site=gpl, sites_dir="test_sites", states_dir="test_states")
     >>> gpl == get_data_for_key("KSK@gpl.txt", sites_dir="test_sites", states_dir="test_states")[0]
     #### /critical section ####
     rmdir(lockdir)
 
-def _test_clean_dirs():
-    """Cleanup the test folders before the tests."""
-    from subprocess import call
-    call(["rm", "-r", "test_sites", "test_states"])
-
 def _test():
     from doctest import testmod
     True
                      states_dir="states"):
     """Get the data for the given key.
 
+    >>> _test_clean_dirs()
     >>> sites, states = get_dataset_for_key("KSK@gpl.txt", sites_dir="test_sites", states_dir="test_states")
     >>> list(sites), list(states)
     ([], [])
 def put_dataset_for_key(key, sites, states,
                      sites_dir="sites",
                      states_dir="states"):
-    """Store the data for a given key."""    
+    """Store the data for a given key.
+
+    >>> _test_create_test_dirs()
+    >>> sites = [{1: 2}, {5:6}, {'path': 'yum'}]
+    >>> states = [{5:7}]
+    >>> put_dataset_for_key("KSK@foo.bar", sites, states, sites_dir="test_sites", states_dir="test_states")
+    >>> si, st = get_dataset_for_key("KSK@foo.bar", sites_dir="test_sites", states_dir="test_states")
+    >>> list(si) == sites
+    True
+    >>> list(st) == states
+    True
+    """
 
     sites_path, states_path = key_to_paths(key, sites_dir, states_dir)
 
         raise IOError("Can’t write to the states datafile. Please check if the states folder exists:" + states_dir)
 
 
+def _test_clean_dirs():
+    """Cleanup the test folders before the tests."""
+    from subprocess import call
+    call(["rm", "-r", "test_sites", "test_states"])
+
+def _test_create_test_dirs():
+    """Create folders for testing."""
+    makedirs("test_sites")
+    makedirs("test_states")
+
 def _test():
     from doctest import testmod
     testmod()