示例#1
0
    def get(self, uid):
        """
        Returns the json representation of a user based on user id.

        ---
        tags:
          - users
        # operationId: find user by id
        parameters:
          - name: id
            in: path
            description: ID of the user to fetch
            required: true
            schema:
              type: string
        responses:
          '200':
            description: user response
          default:
            description: unexpected error

        :param uid:
        :return:
        """
        # Check Firestore to see if UID Already Exists
        if UserDao().user_id_exists(uid):
            user = UserDao().get_user_by_id(uid)
            userDict = user.to_dict()
            return userDict, 200
        else:
            errorResponseDict = {"error": "User Does not Exist"}
            return errorResponseDict, 400
示例#2
0
    def testUserCollectionExists(self):
        """
        TODO: add setUp to create the user specified in uid
        :return:
        """
        uid = "1GFLeGxBaaUvudqh3XYbFv2sRHx2"
        user = UserDao().get_user_by_id(uid)
        self.assertEqual(user.uid, userDict["uid"])
        self.assertEqual(user.membership, userDict["membership"])
        self.assertEqual(user.phone_number, userDict["phone_number"])
        self.assertEqual(user.photo_url, userDict["photo_url"])
        self.assertEqual(user.display_name, userDict["display_name"])
        self.assertEqual(user.pickupAddress, userDict["pickupAddress"])

        print(json.dumps(user.to_dict()))
示例#3
0
 def testGetUser(self):
     uid = userDict["uid"]
     user = UserDao().get_user_by_id(uid)
     print(user.to_dict())