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)
 def test_load_and_save(self):
     self.document.load()
     new_doc = CacheDocument(PROFILE_TATA, PROFILE_DIRECTORY)
     new_doc.import_document(self.document)
     new_doc.del_file(REPO)
     self.assertEquals(new_doc.get_files(), {})
     new_doc.add_file(REPO+"/data/profiles")
     new_doc.add_file(REPO+"/data/subdir1")
     self.assertEquals(new_doc.get_files()[REPO+"/data/profiles"]._shared, True)
     self.assert_(new_doc.get_files()[REPO+"/data/subdir1"] != None)
     new_doc.save()
     check_doc = FileDocument(PROFILE_TATA, PROFILE_DIRECTORY)
     check_doc.load()
     self.assertEquals(check_doc.get_files()[REPO+"/data/profiles"]._shared, True)
     self.assert_(check_doc.get_files()[REPO+"/data/subdir1"] != None)
 def test_import(self):
     # file -> cache
     new_doc = CacheDocument()
     new_doc.import_document(self.document)
     self._assertContent(new_doc)
     # cache -> cache
     cache_doc = CacheDocument()
     cache_doc.import_document(new_doc)
     self._assertContent(cache_doc)
     # cache -> file
     file_doc = FileDocument()
     file_doc.import_document(cache_doc)
     self._assertContent(file_doc)
     # file -> file
     other_doc = FileDocument()
     other_doc.import_document(file_doc)
     self._assertContent(other_doc)
 def test_import(self):
     self.document.load()
     new_doc = CacheDocument(PROFILE_TEST, PROFILE_DIRECTORY)
     new_doc.import_document(self.document)
     self._assertContent(new_doc)