Пример #1
0
 def setUp(self):
     #self.resource = Resource(config.DATABASE_URL)
     config = Config(root_uri=None)
     self.request = RexsterRequest(config)
Пример #2
0
class RestTestCase(unittest.TestCase):
    
    def setUp(self):
        #self.resource = Resource(config.DATABASE_URL)
        config = Config(root_uri=None)
        self.request = RexsterRequest(config)

    def test_init(self):
        config = Config('http://localhost:8182/not-graphs/gratefulgraph')
        #res = Resource(config)

        print config.root_uri
        assert config.root_uri == 'http://localhost:8182/not-graphs/gratefulgraph'
        #assert res.db_name == 'gratefulgraph'

    def test_post(self):
        name_in = "james"
        email_in = "[email protected]"

        path = build_path("vertices")
        params = dict(name=name_in, email=email_in)
        resp = self.request.post(path,params)
                
        assert resp.results._type == 'vertex'
        assert name_in == resp.results.get('name') 
        assert email_in == resp.results.get('email')

        # use the results of this function for get and delete tests 
        return resp
        
    def test_get(self):
        resp1 = self.test_post()
        oid1 = resp1.results.get('_id')
        element_type1 = resp1.results.get('_type')
        name1 = resp1.results.get('name')
        email1 = resp1.results.get('email')

        path = build_path("vertices",oid1)
        params = dict(name=name1, email=email1)
        resp2 = self.request.get(path,params)

        assert oid1 == resp2.results.get('_id')
        assert element_type1 == resp2.results.get('_type')
        assert name1 == resp2.results.get('name')
        assert email1 == resp2.results.get('email')

    def test_delete(self):

        resp1 = self.test_post()
        oid1 = resp1.results.get('_id')
        name1 = resp1.results.get('name')
        email1 = resp1.results.get('email')

        # make sure it's there
        #assert type(oid1) == int

        # delete it
        path = build_path("vertices",oid1)
        params = dict(name=name1, email=email1)
        resp2 = self.request.delete(path,params)

        # verify it's gone
        #assert "SNAPSHOT" in resp2.rexster_version
        #assert type(resp2.get('query_time')) == float
        assert resp2.results == None