Example #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)
Example #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)
Example #3
0
 def test_submit(self):
     config = remus.manage.Config(config_test.DEFAULT_DB, 'process', workdir="tmp_dir")
     manager = remus.manage.Manager(config)
     instance = manager.submit('tableTest', 'test_tableTarget.Submission', {'opcount' : 15})
     manager.wait(instance)
     
     db = remus.db.connect(config_test.DEFAULT_DB)
     for table in db.listTables(instance):
         if table.table.endswith("@error"):
             hasError = False
             for key in db.listKeys(table):
                 hasError = True
             assert not hasError
Example #4
0
 def test_submit(self):
     config = remus.manage.Config(config_test.DEFAULT_DB, 'process', workdir="tmp_dir")
     manager = remus.manage.Manager(config)
     instance = manager.submit('tableTest', 'test_remapTarget.Submission')
     manager.wait(instance)
     
     db = remus.db.connect(config_test.DEFAULT_DB)
     for table in db.listTables(instance):
         if table.table.endswith("@error"):
             keys = list(db.listKeys(table))
             assert len(keys) == 0
     
     table = remus.db.TableRef(instance, "/tableTest/remap_child")
     keys = []
     for key in db.listKeys(table):
         keys.append(key)
     
     assert "mix_0" in keys
     assert "mix_1" in keys
     assert "mix_2" in keys
     assert "mix_3" in keys
     assert "mix_4" in keys