コード例 #1
0
def create_demo_user(guid):
    """
    Create a new user for a single demo

    :param guid:   The demo's guid
    :param {
        "retailerId": "123"
    }

    :return: {
        "id": "123",
        "demoId": "123",
        "username": "******",
        "email": "*****@*****.**"
    }
    """

    # Get inputs and make sure required params are not null
    data = web_utils.get_json_data(request)
    retailer_id = data.get('retailerId')
    web_utils.check_null_input(
        (guid, 'demo for which to create a user'),
        (retailer_id, 'retailer to make a user for the demo'))

    user = user_service.create_user(guid, retailer_id)
    return Response(user, status=201, mimetype='application/json')
コード例 #2
0
def create_demo_user(guid):
    """
    Create a new user for a single demo

    :param guid:   The demo's guid
    :param {
        "retailerId": "123"
    }

    :return: {
        "id": "123",
        "demoId": "123",
        "username": "******",
        "email": "*****@*****.**"
    }
    """

    # Get inputs and make sure required params are not null
    data = web_utils.get_json_data(request)
    retailer_id = data.get('retailerId')
    web_utils.check_null_input((guid, 'demo for which to create a user'),
                               (retailer_id, 'retailer to make a user for the demo'))

    user = user_service.create_user(guid, retailer_id)
    return Response(user,
                    status=201,
                    mimetype='application/json')
コード例 #3
0
    def test_user_create_success(self):
        """With correct values, is a valid user returned?"""

        # Create new user assigned to the first retailer
        user = user_service.create_user(loads(self.demo).get('guid'),
                                        loads(self.retailers)[0].get('id'))

        # TODO: Update to use assertIsInstance(a,b)
        # Check all expected object values are present
        user_json = loads(user)
        self.assertTrue(user_json.get('id'))
        self.assertTrue(user_json.get('demoId'))
        self.assertTrue(user_json.get('email'))
        self.assertTrue(user_json.get('username'))
コード例 #4
0
    def test_user_create_success(self):
        """With correct values, is a valid user returned?"""
        # Create new user assigned to the first retailer
        user = user_service.create_user(
            loads(self.demo).get('guid'),
            loads(self.retailers)[0].get('id'))

        # TODO: Update to use assertIsInstance(a,b)
        # Check all expected object values are present
        user_json = loads(user)
        self.assertTrue(user_json.get('id'))
        self.assertTrue(user_json.get('demoId'))
        self.assertTrue(user_json.get('email'))
        self.assertTrue(user_json.get('username'))
コード例 #5
0
    def test_user_create_success(self):
        """With correct values, is a valid user returned?"""
        # Create new user assigned to the first retailer
        test_utils.mock_with_file(
            httpretty.POST,
            "http://0.0.0.0:3000/api/v1/Demos/DemoGUID/createUser",
            "server/tests/mocks/POST_api_v1_Demos_DemoGUID_createUser_200.json",
            200)

        user = user_service.create_user(
            loads(self.demo).get('guid'),
            loads(self.retailers)[0].get('id'))

        # TODO: Update to use assertIsInstance(a,b)
        # Check all expected object values are present
        user_json = loads(user)
        self.assertTrue(user_json.get('id'))
        self.assertTrue(user_json.get('demoId'))
        self.assertTrue(user_json.get('email'))
        self.assertTrue(user_json.get('username'))