Пример #1
0
class RexsterAutomaticIndexTestCase(unittest.TestCase):
    def setUp(self):
        config = Config(REXSTER_URI)
        self.resource = RexsterResource(config)

    def test_create_automatic_vertex_index(self):
        index_name = "test_automatic_idxV"
        element_class = "TestVertex"
        self.resource.delete_index(index_name)
        resp = self.resource.create_automatic_vertex_index(
            index_name, element_class)
        print "RAW", resp.raw

    def test_create_automatic_indexed_vertex(self):
        index_name = "test_automatic_idxV"
        timestamp = int(time.time())
        timestamp = 12345
        data = dict(name="James", age=34, timestamp=timestamp)
        resp = self.resource.create_indexed_vertex_automatic(data, index_name)
        #print resp.raw
        resp = self.resource.lookup_vertex(index_name, "timestamp", timestamp)
        print "RAW2", resp.raw
Пример #2
0
class RexsterAutomaticIndexTestCase(unittest.TestCase):
    
    def setUp(self):
        config = Config(REXSTER_URI)
        self.resource = RexsterResource(config)

    def test_create_automatic_vertex_index(self):
        index_name = "test_automatic_idxV"
        element_class = "TestVertex"
        self.resource.delete_index(index_name)
        resp = self.resource.create_automatic_vertex_index(index_name,element_class)
        print "RAW", resp.raw

    def test_create_automatic_indexed_vertex(self):
        index_name = "test_automatic_idxV"
        timestamp = int(time.time())
        timestamp = 12345
        data = dict(name="James",age=34,timestamp=timestamp)
        resp = self.resource.create_indexed_vertex_automatic(data,index_name)
        #print resp.raw
        resp = self.resource.lookup_vertex(index_name,"timestamp",timestamp)
        print "RAW2", resp.raw
Пример #3
0
class RexsterIndexTestCase(unittest.TestCase):
    def setUp(self):
        config = Config(REXSTER_URI)
        self.resource = RexsterResource(config)

    #
    # Index Controller Tests
    #

    def test_create_vertex_index(self):
        name = "test_idxV"
        self.resource.delete_vertex_index(name)
        resp = self.resource.create_vertex_index(name, keys=keys)
        assert resp.results.get("name") == name
        assert resp.results.get("class") == "vertex"
        assert resp.results.get("type") == "manual"

    def test_get_all_indices(self):
        resp = self.resource.get_all_indices()
        assert resp.total_size > 1
        # the only indices created by default are automatic
        # so it should be true for whatever index is listed first in the results
        # not true anymore! -- now the default indices are manual
        assert resp.results.next().get('type') == "automatic"

    def test_get_index(self):
        name = "test_idxV"
        self.resource.delete_index(name)
        self.resource.create_vertex_index(name)
        resp = self.resource.get_index(name)
        assert resp.results.get("name") == name
        assert resp.results.get("class") == "vertex"
        assert resp.results.get("type") == "automatic"

    def test_delete_index(self):
        name = "test_idxV"
        resp = self.resource.delete_index(name)

    #
    # Index Container Tests
    #

    def test_put_and_lookup_vertex(self):
        name = "test_idxV"
        self.resource.delete_index(name)
        self.resource.create_vertex_index(name)
        respV = self.resource.create_vertex({'name': 'James'})
        key, value = "name", "James"
        #self.resource.put_vertex(name,key,value,respV.results._id)
        resp = self.resource.lookup_vertex(name, key, value)
        assert resp.total_size == 1
        assert resp.results.next().get("name") == "James"

    def test_remove_vertex(self):
        name = "test_idxV"
        self.resource.delete_index(name)
        self.resource.create_vertex_index(name)
        respV = self.resource.create_vertex({'name': 'James'})
        key, value = "name", "James"
        #self.resource.put_vertex(name,key,value,respV.results._id)
        print "HERE", respV.raw
        self.resource.remove_vertex(name, respV.results.get_id(), key, value)
        resp = self.resource.lookup_vertex(name, key, value)
        assert resp.total_size == 0
Пример #4
0
class RexsterIndexTestCase(unittest.TestCase):

    def setUp(self):
        config = Config(REXSTER_URI)
        self.resource = RexsterResource(config)

    #
    # Index Controller Tests
    #

    def test_create_vertex_index(self):
        name = "test_idxV"
        self.resource.delete_vertex_index(name)
        resp = self.resource.create_vertex_index(name,keys=keys)
        assert resp.results.get("name") == name
        assert resp.results.get("class") == "vertex"  
        assert resp.results.get("type") == "manual"
        
    def test_get_all_indices(self):
        resp = self.resource.get_all_indices()
        assert resp.total_size > 1
        # the only indices created by default are automatic 
        # so it should be true for whatever index is listed first in the results
        # not true anymore! -- now the default indices are manual
        assert resp.results.next().get('type') == "automatic"

    def test_get_index(self):
        name = "test_idxV"
        self.resource.delete_index(name)
        self.resource.create_vertex_index(name)
        resp = self.resource.get_index(name)
        assert resp.results.get("name") == name
        assert resp.results.get("class") == "vertex"  
        assert resp.results.get("type") == "automatic"
                
    def test_delete_index(self):
        name = "test_idxV"
        resp = self.resource.delete_index(name)
    
    #
    # Index Container Tests
    #

    def test_put_and_lookup_vertex(self):
        name = "test_idxV"
        self.resource.delete_index(name)
        self.resource.create_vertex_index(name)
        respV = self.resource.create_vertex({'name':'James'})
        key, value = "name", "James"
        #self.resource.put_vertex(name,key,value,respV.results._id)
        resp = self.resource.lookup_vertex(name,key,value)
        assert resp.total_size == 1
        assert resp.results.next().get("name") == "James"
        
    def test_remove_vertex(self):
        name = "test_idxV"
        self.resource.delete_index(name)
        self.resource.create_vertex_index(name)
        respV = self.resource.create_vertex({'name':'James'})
        key, value = "name", "James"
        #self.resource.put_vertex(name,key,value,respV.results._id)
        print "HERE", respV.raw
        self.resource.remove_vertex(name,respV.results.get_id(),key,value)
        resp = self.resource.lookup_vertex(name,key,value)
        assert resp.total_size == 0