Index: postman/daemon.py
===================================================================
--- postman/daemon.py	(revision 2)
+++ postman/daemon.py	(revision 5)
@@ -42,4 +42,6 @@
             for m in self.mailings.keys():            
                 self.mailings[m].save()
+            return True
+        return False
 
     def load(self):
@@ -59,10 +61,25 @@
                 mailing.load()
                 self.mailings[address] = mailing                
-            
+            return True
+        return False
 
-    def add_mailing_list(self, list_info={}):
+    def clear(self):
+        """
+        Delete all stored data from disk (useful for testing).
+        DANGER: Calling this method will remove all data from disk, leaving the
+        postman instance with no persistence data, if the postman process die,
+        before another .save() call is made, all data will be lost.
+        """
+        if self.dbs['mailings'].exists():
+            # We do not delete each mailing list file, but only the file
+            # containing the list of existing mailing lists
+            self.dbs['mailings'].delete()
+            return True
+        return False
+
+    def add_mailing_list(self, info={}):
         """
         Add a new mailing list to this postman instance. expects one parameter,
-        list_info, which is a dictionary that should contain, at least, the
+        info, which is a dictionary that should contain, at least, the
         following keys:
 
@@ -72,22 +89,24 @@
          
         """
-        if not isinstance(list_info, dict):
-            raise TypeError(list_info, ' is not a valid dictionary')
+        if not isinstance(info, dict):
+            raise TypeError(info, ' is not a valid dictionary')
 
-        if 'name' not in list_info.keys() or \
-           'address' not in list_info.keys() or \
-           'members' not in list_info.keys():
-            raise ValueError(list_info, ' does not seem to be a valid configuration')
+        if 'name' not in info.keys() or \
+           'address' not in info.keys() or \
+           'members' not in info.keys() or \
+           'config' not in info.keys():
+            raise ValueError(info, ' does not seem to be a valid configuration')
         
-        if list_info['address'] in self.mailings_addresses:
-            raise IndexError(list_info['address'],
+        if info['address'] in self.mailings_addresses:
+            raise IndexError(info['address'],
                              ' has been already added to postman')
 
-        mailing = MailingList(list_info['name'], list_info['address'],
-                              list_info['members'])        
+        mailing = MailingList(info['name'], info['address'],
+                              info['members'], info['config'])        
         self.mailings[mailing.address] = mailing
         self.mailings_addresses.append(mailing.address)
         # After adding new mailings, save them to disk
         self.save()
+        return True
         
     def add_mailing_member(self, member_addr=None, list_addr=None):
@@ -109,6 +128,8 @@
             raise IndexError(list_addr, ' is not a valid mailing list')
 
-        member = Member(member_addr)
-        
+        added = self.mailings[list_addr].add_member_by_address(member_addr)
+        if added:
+            self.save()
+        return added
         
 
Index: postman/models.py
===================================================================
--- postman/models.py	(revision 4)
+++ postman/models.py	(revision 5)
@@ -33,5 +33,5 @@
     """
 
-    def __init__(self, name, address, members={}, config={}, storage=None):
+    def __init__(self, name, address, members={}, config={}):
         self.name = name
         self.address = address
@@ -39,8 +39,4 @@
         self.config = config
         self._validate_config() # validate the config parameters
-        self.storage = Storage(os.path.join(self.config['storage'],
-                                            self.address))
-        self.archive = Storage(os.path.join(self.config['archive'],
-                                            self.address))        
         
     def __repr__(self):
@@ -72,5 +68,13 @@
             raise ValueError(address, ' is not a valid email address')
         return address in self.members_addresses()
-        
+
+    @property
+    def storage(self):
+        return Storage(os.path.join(self.config['storage'], self.address))
+
+    @property
+    def archive(self):
+        return Storage(os.path.join(self.config['archive'], self.address))
+    
     def members_addresses(self):
         return self.members.keys()
@@ -97,4 +101,14 @@
         return True
 
+    def info(self):
+        """
+        Returns a dict we can use to add this mailing list to a postman
+        instance
+        """
+        # FIXME: This code could be replaced with something that
+        # automagically generates the dict from the instance attributes
+        return {'name': self.name, 'address': self.address,
+                'members': self.members, 'config': self.config}
+
     def load(self):
         if self.storage.exists():
Index: postman/storage.py
===================================================================
--- postman/storage.py	(revision 4)
+++ postman/storage.py	(revision 5)
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 
-import os, json
+import os, errno, json
+
 
 class JsonStorage():
@@ -17,4 +18,17 @@
         return os.path.exists(self.path)    
 
+    def create(self):
+        """
+        Ensure all the subdirectories in the path to the storage file
+        exist
+        """
+        try:
+            os.makedirs(os.path.dirname(self.path))
+        except OSError, e:
+            # If the dir already exists do not complain, if it is
+            # any other error, raise the exception
+            if e.errno != errno.EEXIST:
+                raise
+    
     def jsonize(self, obj):
         """
@@ -45,4 +59,7 @@
         
     def write(self, data):
+        if not self.exists():
+            # ensure the path to the storage file exists
+            self.create()
         with open(self.path, 'w') as storage:
             json.dump(data, storage, sort_keys=True, indent=4,
@@ -64,2 +81,10 @@
         return data
 
+    def delete(self):
+        """
+        Remove the storage file
+        """
+        if self.exists():
+            os.remove(self.path)
+            return True
+        return False
Index: postman/tests/__init__.py
===================================================================
--- postman/tests/__init__.py	(revision 2)
+++ postman/tests/__init__.py	(revision 5)
@@ -3,3 +3,3 @@
 from models import *
 from mta import *
-
+from daemon import *
Index: postman/tests/daemon.py
===================================================================
--- postman/tests/daemon.py	(revision 5)
+++ postman/tests/daemon.py	(revision 5)
@@ -0,0 +1,122 @@
+# -*- coding: utf-8 -*-
+
+import os
+from unittest import TestCase
+from postman.daemon import Postman
+from postman.models import Member, MailingList
+from postman.storage import JsonStorage as Storage
+
+
+class TestPostman(TestCase):
+    """
+    postman.daemon.Postman tests.
+
+    Remember to call the .clear() method of postman after each test, so
+    the temp storage files are deleted
+    """
+    def setUp(self):
+        config = {'private': False, 'archive': '/tmp/postman-tests/archive',
+                  'storage': '/tmp/postman-tests/storage'}
+        self.mailing_list = MailingList('test_list', 'test_list@example.com',
+                                        members={}, config=config)
+        self.member =  Member('test@example.com')
+
+    def test___init__(self):
+        postman = Postman()
+        self.assertIsInstance(postman, Postman)
+        self.assertEqual(postman.mailings, {})
+        self.assertEqual(postman.mailings_addresses, [])
+        self.assertIsInstance(postman.dbs, dict)
+        self.assertTrue('mailings' in postman.dbs.keys())
+        self.assertTrue('members' in postman.dbs.keys())
+        self.assertIsInstance(postman.dbs['mailings'], Storage)
+        self.assertIsInstance(postman.dbs['members'], Storage)
+
+    def test_save(self):
+        postman = Postman()
+        self.assertFalse(postman.save())
+        postman.add_mailing_list(self.mailing_list.info())
+        self.assertTrue(postman.save())
+        # FIXME: We have to test here that the generated json file
+        # contains the data it should contain
+
+        # Clear the files created by the tests
+        postman.clear()
+
+    def test_load(self):
+        postman = Postman()
+        self.assertFalse(postman.mailings)
+        self.assertFalse(postman.mailings_addresses)
+        self.assertFalse(postman.load())
+        postman.add_mailing_list(self.mailing_list.info())
+        self.assertTrue(postman.load())
+
+        # Check that another postman instance is able to load the saved data
+        postman_load = Postman()
+        self.assertFalse(postman_load.mailings)
+        self.assertFalse(postman_load.mailings_addresses)
+        postman_load.load()
+        self.assertTrue(postman_load.mailings)
+        self.assertIsInstance(postman_load.mailings, dict)
+        self.assertTrue(postman_load.mailings_addresses)
+        self.assertIsInstance(postman_load.mailings_addresses, list)        
+
+        # Clear the files created by the tests
+        postman.clear()
+
+    def test_clear(self):
+        postman = Postman()
+        self.assertFalse(postman.clear())
+        postman.add_mailing_list(self.mailing_list.info())
+        self.assertTrue(postman.clear())
+
+    def test_add_mailing_list(self):
+        postman = Postman()
+        with self.assertRaises(TypeError):
+            # test improper info values
+            postman.add_mailing_list(['a list', 'is an', 'invalid parameter'])
+            postman.add_mailing_list(self.mailing_list)
+        with self.assertRaises(ValueError):
+            #test incomplete/missing info values
+            postman.add_mailing_list()
+            postman.add_mailing_list({'name': 'missing info'})
+            postman.add_mailing_list({'address': 'missing info'})
+            postman.add_mailing_list({'name': 'missing info',
+                                      'address': 'missing info'})
+        # test mailing lists can be added
+        self.assertTrue(postman.add_mailing_list(self.mailing_list.info()))
+        self.assertTrue(postman.mailings)
+        self.assertIsInstance(postman.mailings, dict)
+        self.assertTrue(postman.mailings_addresses)
+        self.assertIsInstance(postman.mailings_addresses, list)
+        with self.assertRaises(IndexError):
+            # test what happens when the mailing has been already added
+            postman.add_mailing_list(self.mailing_list.info())
+
+        # Clear the files created by the tests
+        postman.clear()
+
+    def test_add_mailing_member(self):
+        postman = Postman()
+        postman.add_mailing_list(self.mailing_list.info())
+        with self.assertRaises(ValueError):
+            # test what happens if we call the method without proper
+            # parameters
+            postman.add_mailing_member()
+            postman.add_mailing_member(None, None)
+            postman.add_mailing_member(None, 'test_list@example.net')
+            postman.add_mailing_member('test@example.net', None)
+            postman.add_mailing_member('test@example', 'test_list@example.net')
+        with self.assertRaises(IndexError):
+            # test if we try to add a member to a non-existing mailing list
+            postman.add_mailing_member('test@example.net',
+                                       'test_list_b@example.net')
+        # Test adding a member
+        self.assertTrue(postman.add_mailing_member('test@example.net',
+                                                   self.mailing_list.address))
+        # Test trying to re-add that user
+        self.assertFalse(postman.add_mailing_member('test@example.net',
+                                                    self.mailing_list.address))
+
+        # Clear the files created by the tests
+        postman.clear()
Index: postman/tests/mta.py
===================================================================
--- postman/tests/mta.py	(revision 2)
+++ postman/tests/mta.py	(revision 5)
@@ -3,7 +3,6 @@
 import os, sys
 from unittest import TestCase
-
+from postman.mta import Sendmail
 from postman.models import Member, MailingList
-from postman.mta import Sendmail
 
 
