示例#1
0
    def test_dbi(self):
        
        instance = str(uuid.uuid4())
        db = remus.db.connect(config_test.DEFAULT_DB)
        
        db.createInstance(instance, {"info" : "test"} )
        
        table_a_ref = remus.db.TableRef(instance, "/test1")
        db.createTable(table_a_ref, { "info" : "other"}    )
        
        db.addData(table_a_ref, "key_1", {"data" : "key_1"})
        db.addData(table_a_ref, "key_2", {"data" : "key_2"})
        
        db.flush()
        
        i = {}
        for key in db.listKeys(table_a_ref):
            i[key] = True
        
        assert "key_1" in i
        assert "key_2" in i

        count = 0
        for key, val in db.listKeyValue(table_a_ref):
            assert val['data'] == key
            count += 1
        assert count == 2
        
        print db.hasTable(table_a_ref)
        assert db.hasTable(table_a_ref) == True
        
        db.deleteTable(table_a_ref)
        
        assert db.hasTable(table_a_ref)==False
                
        table_b_ref = remus.db.TableRef(instance, "/test_b")
        db.createTable(table_b_ref, {})
        db.addData(table_b_ref, "key_1", {})
        db.copyTo("run_tests.py", table_b_ref, "key_1", "run_tests.py")
        
        db.flush()
        
        db.copyFrom("tmp.out", table_b_ref, "key_1", "run_tests.py")
        
        assert filecmp.cmp("tmp.out", "run_tests.py")
        
        assert db.hasAttachment(table_b_ref, "key_1", "run_tests.py")
        assert db.hasAttachment(table_b_ref, "key_1", "blabla.py") == False
        
        assert db.listAttachments(table_b_ref, "key_1") == ["run_tests.py"]
        
        
        db.deleteInstance(instance)
示例#2
0
    def test_dbi(self):

        instance = str(uuid.uuid4())
        db = remus.db.connect(config_test.DEFAULT_DB)

        db.createInstance(instance, {"info": "test"})

        table_a_ref = remus.db.TableRef(instance, "/test1")
        db.createTable(table_a_ref, {"info": "other"})

        db.addData(table_a_ref, "key_1", {"data": "key_1"})
        db.addData(table_a_ref, "key_2", {"data": "key_2"})

        db.flush()

        i = {}
        for key in db.listKeys(table_a_ref):
            i[key] = True

        assert "key_1" in i
        assert "key_2" in i

        count = 0
        for key, val in db.listKeyValue(table_a_ref):
            assert val['data'] == key
            count += 1
        assert count == 2

        print db.hasTable(table_a_ref)
        assert db.hasTable(table_a_ref) == True

        db.deleteTable(table_a_ref)

        assert db.hasTable(table_a_ref) == False

        table_b_ref = remus.db.TableRef(instance, "/test_b")
        db.createTable(table_b_ref, {})
        db.addData(table_b_ref, "key_1", {})
        db.copyTo("run_tests.py", table_b_ref, "key_1", "run_tests.py")

        db.flush()

        db.copyFrom("tmp.out", table_b_ref, "key_1", "run_tests.py")

        assert filecmp.cmp("tmp.out", "run_tests.py")

        assert db.hasAttachment(table_b_ref, "key_1", "run_tests.py")
        assert db.hasAttachment(table_b_ref, "key_1", "blabla.py") == False

        assert db.listAttachments(table_b_ref, "key_1") == ["run_tests.py"]

        db.deleteInstance(instance)
示例#3
0
    def test_file(self):
        
        instance = str(uuid.uuid4())
        db = remus.db.connect(config_test.DEFAULT_DB)
        
        db.createInstance(instance, {"info" : "test"} )
        
        table_a_ref = remus.db.TableRef(instance, "/test_file")
        db.createFile(table_a_ref, { "info" : "other"}    )
        
        db.copyTo("run_tests.py", table_a_ref)
        
        assert db.hasTable(table_a_ref) == False
        assert db.hasFile(table_a_ref) == True

        db.copyFrom("tmp.out", table_a_ref)
        assert filecmp.cmp("tmp.out", "run_tests.py")
        
        db.deleteFile(table_a_ref)
        assert db.hasFile(table_a_ref)==False
        
        db.deleteInstance(instance)