コード例 #1
0
ファイル: TestAccount.py プロジェクト: YTKme/Python-D365API
    def setUpClass(cls):
        """Prepare test set up class.

        Get the data from JSON (JavaScript Object Notation) file and
        login.
        """

        # Get the current directory of the file
        current_directory = os.path.dirname(os.path.abspath(__file__))
        # Get the path of the Test Data file
        cls.test_data_file = os.path.join(current_directory, TEST_FILE)

        # Open the file for reading
        with open(cls.test_data_file, 'r') as f:
            cls.data = json.load(f)

        # Get the hostname from the Test Data
        cls.hostname = cls.data['organizations']['name']

        # Get the user data for success login
        oauth_1_0_user_success = cls.data['systemusers']['oauth_1_0_user_success']

        # Create an instance of Access object and login
        cls.access = Access(hostname=cls.hostname,
                            client_id=oauth_1_0_user_success['client_id'],
                            client_secret=oauth_1_0_user_success['client_secret'],
                            tenant_id=oauth_1_0_user_success['tenant_id']).login()

        # Create an instance of Entity
        cls.entity = Entity(cls.access, cls.hostname)
コード例 #2
0
    def setUpClass(cls):
        """Prepare test set up class.

        Get the data from JSON (JavaScript Object Notation) file and
        login.
        """

        # Get the current directory of the file
        current_directory = os.path.dirname(os.path.abspath(__file__))
        # Get the path of the Test Data file
        cls.test_data_file = os.path.join(current_directory, "TestData.json")

        # Open the file for reading
        with open(cls.test_data_file, "r") as f:
            cls.data = json.load(f)

        # Get the hostname from the Test Data
        cls.hostname = cls.data["organizations"]["name"]

        # Get the user data for success login
        user_rest_v1_success = cls.data["systemusers"]["user_rest_v1_success"]

        # Create an instance of Access object and login
        cls.access = Access(
            hostname=cls.hostname,
            client_id=user_rest_v1_success["client_id"],
            client_secret=user_rest_v1_success["client_secret"],
            tenant_id=user_rest_v1_success["tenant_id"]).login()

        # Create an instance of Entity
        cls.entity = Entity(cls.access, cls.hostname)
コード例 #3
0
ファイル: TestAccount.py プロジェクト: YTKme/Python-D365API
    def setUpClass(cls):
        """Prepare test set up class.

        Get the data from JSON (JavaScript Object Notation) file and
        login.
        """

        # Get the current directory of the file
        current_directory = os.path.dirname(os.path.abspath(__file__))
        # Get the path of the Test Data file
        cls.test_data_file = os.path.join(current_directory, TEST_FILE)

        # Open the file for reading
        with open(cls.test_data_file, 'r') as f:
            cls.data = json.load(f)

        # Get the hostname from the Test Data
        cls.hostname = cls.data['organizations']['name']

        # Get the user data for success login
        oauth_1_0_user_success = cls.data['systemusers']['oauth_1_0_user_success']

        # Create an instance of Access object and login
        cls.access = Access(hostname=cls.hostname,
                            client_id=oauth_1_0_user_success['client_id'],
                            client_secret=oauth_1_0_user_success['client_secret'],
                            tenant_id=oauth_1_0_user_success['tenant_id']).login()

        # Create an instance of Entity
        cls.entity = Entity(cls.access, cls.hostname)

        # Generate a random number
        random_number = random.randrange(10000, 99999)

        # Create Account using payload
        payload = {
            'name': f'Account-{random_number}'
        }

        # Make a request to create the Account
        # Get the return unique identifier (ID)
        # The payload need to be serialized to JSON formatted str (json.dumps)
        cls.account_id = cls.entity.accounts.create(json.dumps(payload))

        # Create Opportunity using payload
        payload = {
            'name': f'Opportunity-{random_number}'
        }

        # Make a request to create the Opportunity
        cls.opportunity_id = cls.entity.opportunities.create(json.dumps(payload))

        # Make a request to associate Account and Opportunity
        cls.entity.accounts.associate(primary_id=cls.account_id,
                                      collection='opportunity_customer_accounts',
                                      secondary='opportunities',
                                      secondary_id=cls.opportunity_id)
コード例 #4
0
    def setUpClass(cls):
        """Prepare test set up class.

        Get the data from JSON (JavaScript Object Notation) file and
        login.
        """

        # Get the current directory of the file
        current_directory = os.path.dirname(os.path.abspath(__file__))
        # Get the path of the Test Data file
        cls.test_data_file = os.path.join(current_directory, "TestData.json")

        # Open the file for reading
        with open(cls.test_data_file, "r") as f:
            cls.data = json.load(f)

        # Get the hostname from the Test Data
        cls.hostname = cls.data["organizations"]["name"]

        # Get the user data for success login
        user_rest_v1_success = cls.data["systemusers"]["user_rest_v1_success"]

        # Create an instance of Access object and login
        cls.access = Access(
            hostname=cls.hostname,
            client_id=user_rest_v1_success["client_id"],
            client_secret=user_rest_v1_success["client_secret"],
            tenant_id=user_rest_v1_success["tenant_id"]).login()

        # Create an instance of Entity
        cls.entity = Entity(cls.access, cls.hostname)

        # Create the payload
        payload = {
            # Generate a random Account Name
            "name": "Account-{}".format(random.randrange(10000, 99999))
        }

        # Make a request to create the Account
        # Get the return unique identifier (ID)
        # The payload need to be serialized to JSON formatted str (json.dumps)
        account_id = cls.entity.accounts.create(json.dumps(payload))

        # Create the dictionary
        cls.data["accounts"]["delete_account_success"] = {}
        # Create or update the Account ID in the Test Data
        cls.data["accounts"]["delete_account_success"]["id"] = account_id

        # Write the new Test Data to file
        with open(cls.test_data_file, "w") as f:
            json.dump(cls.data, f)