Пример #1
0
 def test_invalid_password(self):
     data = self.parameters()
     data["password"] = str(uuid.uuid4())
     rv = self.app.post(self.endpoint, data=data)
     self.check_status_code(rv.status_code)
     msg = "login should have failed, invalid password"
     self.assertFalse(safe_json_loads(rv.data)["success"], msg=msg)
Пример #2
0
 def test_basic(self):
     rv = self.app.post(self.endpoint, data=self.parameters())
     response = safe_json_loads(rv.data)
     self.check_status_code(rv.status_code)
     assert response["success"] == True
     self.issue_node = graph.nodes.find("Issue", response["issue_id"])
     assert self.issue_node, "No matching node found"
     assert self.issue_node.properties["name"] == self.name
Пример #3
0
    def test(self):
        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 = safe_json_loads(rv.data)
        expected = dict(success=False,
                        error="User <{0}> already exists".format(self.user_id))
        self.assertEqual(response, expected)
Пример #4
0
    def test(self):
        graph.create_user(self.data)

        # submit GET request to retrieve user data
        rv = self.app.get("/api/user", data=dict(id=self.user_id))

        # confirm JSON response matches what we expect
        response = safe_json_loads(rv.data)
        expected = dict(id=self.data["username"],
                        name=self.data["name"],
                        city=self.data["city"])
        self.assertEqual(response, expected)
Пример #5
0
    def test(self):
        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 = safe_json_loads(rv.data)
        expected = dict(
            success=False,
            error="User <{0}> already exists".format(self.user_id)
        )
        self.assertEqual(response, expected)
Пример #6
0
    def test(self):
        graph.create_user(self.data)

        # submit GET request to retrieve user data
        rv = self.app.get("/api/user", data=dict(id=self.user_id))
        
        # confirm JSON response matches what we expect
        response = safe_json_loads(rv.data)
        expected = dict(
            id=self.data["username"],
            name=self.data["name"],
            city=self.data["city"]
        )
        self.assertEqual(response, expected)
Пример #7
0
    def test(self):
        graph.nodes.delete("User", self.user_id)

        # submit POST request to create new user
        rv = self.app.post(self.endpoint, data=self.data)

        # confirm JSON response matches what we expect
        response = safe_json_loads(rv.data)
        expected = dict(success=True, error="")
        self.assertEqual(response, expected)

        # query graph directly and verify node exists
        node = graph.nodes.find("User", self.user_id)
        self.assertIsNotNone(node, msg="User node is null")
        self.assertEqual(node.properties["node_id"], self.user_id)
Пример #8
0
 def test(self):
     graph.nodes.delete("User", self.user_id)
     
     # submit POST request to create new user
     rv = self.app.post(self.endpoint, data=self.data)
     
     # confirm JSON response matches what we expect
     response = safe_json_loads(rv.data)
     expected = dict(success=True, error="")
     self.assertEqual(response, expected)
     
     # query graph directly and verify node exists
     node = graph.nodes.find("User", self.user_id)
     self.assertIsNotNone(node, msg="User node is null")
     self.assertEqual(node.properties["node_id"], self.user_id)
Пример #9
0
 def check_response(self, expected, data):
     response = safe_json_loads(data)
     error = "expecting: {0}, actual: {1}".format(expected, response)
     assert response == expected, error
Пример #10
0
 def check_response(self, data):
     response = safe_json_loads(data)
     actual = [node["node_id"] for node in response["nodes"]]
     msg = "response nodes contain an invalid node_id"
     for node_id in [node.node_id for node in self.children]:
         self.assertIn(node_id, actual, msg=msg)
Пример #11
0
 def check_response(self, data):
     response = safe_json_loads(data)
     actual = [ node["node_id"] for node in response["nodes"] ]
     msg= "response nodes contain an invalid node_id"
     for node_id in [ node.node_id for node in self.children ]:
         self.assertIn(node_id, actual, msg=msg)
Пример #12
0
 def test_valid(self):
     rv = self.app.post(self.endpoint, data=self.parameters())
     self.check_status_code(rv.status_code)
     self.assertTrue(safe_json_loads(rv.data)["success"],
                     msg="success not true")
Пример #13
0
 def runner(self):
     data = dict(id=self.node.node_id)
     rv = self.app.get(self.endpoint, data=data)
     response = safe_json_loads(rv.data)
     contains_id = set(data.items()).issubset(set(response.items()))
     self.assertTrue(contains_id, msg="response does not contain node id")
Пример #14
0
 def check_response(self, expected, data):
     response = safe_json_loads(data)
     error = "expecting: {0}, actual: {1}".format(expected, response)
     assert response == expected, error
Пример #15
0
 def test_api_index(self):
     rv = self.app.get('/api') 
     expected = dict(response="API Index")
     response = safe_json_loads(rv.data)
     self.assertEqual(response, expected)
Пример #16
0
 def runner(self):
     data = dict(id=self.node.node_id)
     rv = self.app.get(self.endpoint, data=data)
     response = safe_json_loads(rv.data)
     contains_id = set(data.items()).issubset(set(response.items()))
     self.assertTrue(contains_id, msg="response does not contain node id")
Пример #17
0
 def test_api_index(self):
     rv = self.app.get('/api')
     expected = dict(response="API Index")
     response = safe_json_loads(rv.data)
     self.assertEqual(response, expected)