소스 검색

Add all methods to mongodb

oz123 10 년 전
부모
커밋
885dcc7f33
2개의 변경된 파일10개의 추가작업 그리고 25개의 파일을 삭제
  1. 2 2
      pwman/data/drivers/mongodb.py
  2. 8 23
      tests/test_mongodb.py

+ 2 - 2
pwman/data/drivers/mongodb.py

@@ -94,7 +94,7 @@ class MongoDB(Database):
         pass
 
     def removenodes(self, nid):
-        pass
+        self._db.nodes.remove({'_id': {'$in': nid}})
 
     def fetch_crypto_info(self):
         pass
@@ -111,4 +111,4 @@ class MongoDB(Database):
         return key
 
     def close(self):
-        pass
+        self._con.close()

+ 8 - 23
tests/test_mongodb.py

@@ -52,6 +52,8 @@ class TestMongoDB(unittest.TestCase):
         coll = cls.db._db['crypto']
         coll.drop()
         cls.db._db['counters'].drop()
+        cls.db._db['nodes'].drop()
+        cls.db.close()
 
     def test_1_con(self):
         self.assertIsInstance(self.db._con, pymongo.Connection)
@@ -95,39 +97,22 @@ class TestMongoDB(unittest.TestCase):
         retb = self.db.getnodes([])
         self.assertListEqual(ret, retb)
 
-    @unittest.skip("")
+    @unittest.skip("tags are created in situ in mongodb")
     def test_7_get_or_create_tag(self):
-        s = self.db._get_or_create_tag("SECRET")
-        s1 = self.db._get_or_create_tag("SECRET")
-
-        self.assertEqual(s, s1)
+        pass
 
-    @unittest.skip("")
+    @unittest.skip("tags are removed with their node")
     def test_7a_clean_orphans(self):
+        pass
 
-        self.db._clean_orphans()
-        rv = self.db._get_tag("SECRET")
-        self.assertIsNone(rv)
-
-    @unittest.skip("")
     def test_8_remove_node(self):
         self.db.removenodes([1])
         n = self.db.listnodes()
         self.assertEqual(len(n), 0)
 
-    @unittest.skip("")
+    @unittest.skip("No schema migration with mongodb")
     def test_9_check_db_version(self):
-
-        dburi = "mysql://pwman:123456@localhost:3306/pwmantest"
-        v = self.db.check_db_version(urlparse(dburi))
-        self.assertEqual(v, '0.6')
-        self.db._cur.execute("DROP TABLE DBVERSION")
-        self.db._con.commit()
-        v = self.db.check_db_version(urlparse(dburi))
-        self.assertEqual(v, None)
-        self.db._cur.execute("CREATE TABLE DBVERSION("
-                             "VERSION TEXT NOT NULL) ")
-        self.db._con.commit()
+        pass
 
 
 if __name__ == '__main__':