class ProfileTest(unittest.TestCase):
    """test interactactions between profiles"""
    
    def setUp(self):
        """override one in unittest.TestCase"""
        # bruce
        doc = FileDocument(PROFILE_BRUCE, PROFILE_DIRECTORY)
        self.assert_(doc.load())
        self.bruce_doc = CacheDocument(PROFILE_BRUCE, PROFILE_DIRECTORY)
        self.bruce_doc.import_document(doc)
        # demi
        self.demi_doc = FileDocument(PROFILE_DEMI, PROFILE_DIRECTORY)
        self.assert_(self.demi_doc.load())

    def test_bruce(self):
        """import bruce data"""
        self.assertEquals("Bruce", self.bruce_doc.get_firstname())
        self.assertEquals("Willis", self.bruce_doc.get_lastname())
        self.assertEquals("*****@*****.**", self.bruce_doc.get_email())
        self.assertEquals({'City': u'', 'Country': u'',
                           'Favourite Book': u'', 'music': u'jazz',
                           'Favourite Movie': u'', 'Sport': u'', 'Studies': u'',
                           'film': u'Die Hard'},
                          self.bruce_doc.get_custom_attributes())

    def test_peer_status(self):
        self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.pseudo), False)
        self.demi_doc.fill_data((self.bruce_doc.pseudo, self.bruce_doc))
        self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.pseudo), True)
        self.demi_doc.make_friend(self.bruce_doc.pseudo)
        self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.pseudo), True)
        self.demi_doc.unmark_peer(self.bruce_doc.pseudo)
        self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.pseudo), False)
class ProfileTest(unittest.TestCase):
    """test interactactions between profiles"""
    
    def setUp(self):
        """override one in unittest.TestCase"""
        # bruce
        doc = FileDocument()
        self.assert_(doc.load(TEST_BRUCE))
        self.bruce_doc = CacheDocument()
        self.bruce_doc.import_document(doc)
        # demi
        self.demi_doc = FileDocument()
        self.assert_(self.demi_doc.load(TEST_DEMI))

    def test_bruce(self):
        """import bruce data"""
        self.assertEquals("Bruce", self.bruce_doc.get_firstname())
        self.assertEquals("Willis", self.bruce_doc.get_lastname())
        self.assertEquals("john", self.bruce_doc.get_pseudo())
        self.assertEquals("*****@*****.**", self.bruce_doc.get_email())
        self.assertEquals("01/06/1947", self.bruce_doc.get_birthday())
        self.assertEquals("English", self.bruce_doc.get_language())
        self.assertEquals("Hill", self.bruce_doc.get_address())
        self.assertEquals("920", self.bruce_doc.get_postcode())
        self.assertEquals("Los Angeles", self.bruce_doc.get_city())
        self.assertEquals("US", self.bruce_doc.get_country())
        self.assertEquals("Lots of movies, quite famous, doesn't look much but very effective",
                          self.bruce_doc.get_description())
        self.assertEquals([u'cinema', u'theatre', u'cop', u'action'], self.bruce_doc.get_hobbies())
        self.assertEquals({'music': u'jazz', 'film': u'Die Hard'},
                          self.bruce_doc.get_custom_attributes())

    def test_peer_status(self):
         self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.get_pseudo()), False)
         self.demi_doc.fill_data((self.bruce_doc.get_pseudo(), self.bruce_doc))
         self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.get_pseudo()), False)
         self.demi_doc.make_friend(self.bruce_doc.get_pseudo())
         self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.get_pseudo()), True)
         self.demi_doc.unmark_peer(self.bruce_doc.get_pseudo())
         self.assertEquals(self.demi_doc.has_peer(self.bruce_doc.get_pseudo()), False)