Beispiel #1
0
    def test_login_created(self):
        result = post(self.port, "auth/login", login_data)

        self.assertIn("data", result)
        self.assertIn("_id", result["data"])
        _id = result["data"]["_id"]

        result = post(self.port, "auth/login", login_data)

        self.assertIn("data", result)
        self.assertIn("_id", result["data"])
        self.assertEqual(_id, result["data"]["_id"])
Beispiel #2
0
    def test_create(self):
        # headers for auth/login is used for request params
        post(self.port, "auth/login", headers)
        user = post(self.port, "user/create", user_data, headers)
        self.assertIn("data", user)
        self.assertIn("userId", user["data"])
        self.assertIn("name", user["data"])

        # check if the client is trying to create an existing user
        user = post(self.port, "user/create", user_data, headers)
        self.assertIn("data", user)
        self.assertIn("userId", user["data"])
        self.assertIn("name", user["data"])
Beispiel #3
0
    def test_post(self):
        result = post(self.port, "example", {
            "data": "example data"
        })

        self.assertIn("data", result)
        self.assertEqual(result["data"], "example data")
Beispiel #4
0
    def test_update(self):
        update_dic = { "update_dic":
                { "new_field": "new what?", "location": "is dis updated" }
        }
        # headers for auth/login is used for request params
        post(self.port, "auth/login", headers)
        post(self.port, "user/create", user_data, headers)
        user = post(self.port, "user/update", update_dic, headers)

        self.assertIn("data", user)
        self.assertIn("userId", user["data"])
        self.assertIn("new_field", user["data"])
        self.assertIn("location", user["data"])
        self.assertEqual(
            update_dic["update_dic"]["location"],
            user["data"]["location"]
        )
Beispiel #5
0
 def test_bad_json_post(self):
     result = post(self.port, "badexample", {
         "data": "bad example"
     })
     self.assertEqual(result["status"], 400)
Beispiel #6
0
 def test_bad_post_missing(self):
     result = post(self.port, "notexample", {
         "data": "example data"
     })
     self.assertEqual(result["status"], 404)
Beispiel #7
0
 def test_bad_post(self):
     result = post(self.port, "example", {
         "not_data": "example data"
     })
     self.assertEqual(result["status"], 400)
Beispiel #8
0
    def test_create(self):
        result = post(self.port, "path/create", {"name": "Job", "creatorId": "randomCreatorId"})

        self.assertIn("data", result)
        self.assertIn("_id", result["data"])
Beispiel #9
0
 def test_missing_credentials(self):
     result = post(self.port, "user/create", user_data, {})
     self.assertEquals(result["status"], 401)
Beispiel #10
0
    def test_non_authenticated(self):
        result = post(self.port, "user/create", user_data, headers)

        self.assertIn("data", result)
        self.assertEqual("User not authenticated", result["data"])