Commits

Anonymous committed 7ff92ed

Updated the tests

Comments (0)

Files changed (3)

dragoman/lib/test/test_api.py

     def setup_class(self):
         # clear the cache
         cache = '.dragoman_client_cache'
-        for f in os.listdir(cache):
-            os.remove(os.path.join(cache, f))
+        if os.path.isdir(cache):
+            for f in os.listdir(cache):
+                os.remove(os.path.join(cache, f))
+        elif os.path.isfile(cache):
+            os.remove(cache)
 
         # get a client
         self.http = httplib2.Http(cache)

dragoman/lib/test/test_gettext_import.py

 
 from dragoman.lib.storage import Catalog
 from dragoman.lib.client import Connection as DMConnection
-from dragoman.lib.gettext_tools import GettextImporter, GettextCatalog
+from dragoman.lib.gettext_tools import GettextCatalog
 from dragoman.lib.testing import start_test_server
 
 
         assert last['msgid'] == "Each %(type)s must sum to exactly %(target)s."
         assert last['msgstr'] == "每种%(type)s相加必须等于%(target)s。"
         
-
-
     def test_remote_import(self):
-        importer = GettextImporter(self.api_base, 'test_import')
-        result = importer.do_import(PO, LANG)
-        assert result
-
+        c = DMConnection(self.api_base)
+        c.test_import[LANG].bulk_by_po(PO)
+        
         c = DMConnection(self.api_base)['test_import'][LANG]
         c.clear_cache()
         result = c("Interview with visa %s cleared for restart")

dragoman/lib/test/test_storage.py

     def test_add_phrase(self):
         c = storage.Catalog('foo', 'es')
         c.db.reset()
+
+        # make sure there isn't an original
+        c._get = lambda x: False
+		
         # adds uses an percent encoded phrase
         c.add('Hello%20World', 'Hola Globo')
 
         db = LikeDingus()
 
         # finds matches before adding
-        docs = list(db[c._collection].find({'phrase': 'Hello World'}))
+        docs = db[c._collection].find_one({'phrase': 'Hello World'})
 
         # update the original or insert
         orig = docs.pop()