Exemple #1
0
    def test_create_existing(self):
        # make sure user exists
        graph.create_user(self.data)
        
        # submit POST request to create a user that already exists
        rv = self.app.post(self.endpoint, data=self.data)

        # confirm JSON response matches what we expect
        response = json.loads(rv.data)
        expected = dict(
            node_id=self.user,
            error="User <{0}> already exists".format(self.user)
        )
        self.assertEqual(response, expected)

        # clean up
        graph.delete_user(self.user)
Exemple #2
0
    def test_get_user(self):
        # make sure user exists
        graph.create_user(self.data)

        # submit GET request to retrieve user data
        rv = self.app.get("/api/user", data=dict(id=self.user))
        
        # confirm JSON response matches what we expect
        response = json.loads(rv.data)
        expected = dict(
            id=self.user,
            name=self.data["name"],
            city=self.data["city"]
        )
        self.assertEqual(response, expected)
           
        # clean up
        graph.delete_user(self.user)
Exemple #3
0
    def test_create_new(self):
        # make sure user does not exist
        graph.delete_user(self.user)

        # submit POST request to create new user
        rv = self.app.post(self.endpoint, data=self.data)
        
        # confirm JSON response matches what we expect
        response = json.loads(rv.data)
        expected = dict(
            node_id=self.user,
            success="User <{0}> created".format(self.user)
        )
        self.assertEqual(response, expected)
        
        # query graph directly and verify node exists
        node = graph.find_node("User", self.user)
        self.assertEqual(node.properties["node_id"], self.user)
   
        # clean up
        graph.delete_user(self.user)