<commit_before>"""
Tests for the Finances API class.
"""
import unittest
import datetime
import mws
from .utils import CommonRequestTestTools


class FinancesTestCase(unittest.TestCase, CommonRequestTestTools):
    """
    Test cases for Finances.
    """
    # TODO: Add remaining methods for Finances
    def setUp(self):
        self.api = mws.Finances(
            self.CREDENTIAL_ACCESS,
            self.CREDENTIAL_SECRET,
            self.CREDENTIAL_ACCOUNT,
            auth_token=self.CREDENTIAL_TOKEN
        )
        self.api._test_request_params = True

    def test_list_financial_event_groups(self):
        """
        ListFinancialEventGroups operation.
        """
        created_after = datetime.datetime.utcnow()
        created_after_stamp = created_after.isoformat()
        created_before = datetime.datetime.utcnow()
        created_before_stamp = created_before.isoformat()
        max_results = 659
        params = self.api.list_financial_event_groups(
            created_after=created_after,
            created_before=created_before,
            max_results=max_results,
        )
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEventGroups'
        assert params['FinancialEventGroupStartedAfter'] == created_after_stamp
        assert params['FinancialEventGroupStartedBefore'] == created_before_stamp
        assert params['MaxResultsPerPage'] == str(max_results)

    def test_list_financial_event_groups_by_next_token(self):
        """
        ListFinancialEventGroupsByNextToken operation, via method decorator.
        """
        next_token = '<PASSWORD>'
        params = self.api.list_financial_event_groups(next_token=next_token)
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEventGroupsByNextToken'
        assert params['NextToken'] == next_token

    def test_list_financial_event_groups_by_next_token_alias(self):
        """
        ListFinancialEventGroupsByNextToken operation, via alias method.
        """
        next_token = '<PASSWORD>'
        params = self.api.list_financial_event_groups_by_next_token(next_token)
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEventGroupsByNextToken'
        assert params['NextToken'] == next_token

    def test_list_financial_events(self):
        """
        ListFinancialEvents operation.
        """
        posted_after = datetime.datetime.utcnow()
        posted_after_stamp = posted_after.isoformat()
        posted_before = datetime.datetime.utcnow()
        posted_before_stamp = posted_before.isoformat()
        amazon_order_id = '123-4567890-1234567'
        financial_event_group_id = '22YgYW55IGNhcm5hbCBwbGVhEXAMPLE'
        max_results = 156
        params = self.api.list_financial_events(
            financial_event_group_id=financial_event_group_id,
            amazon_order_id=amazon_order_id,
            posted_after=posted_after,
            posted_before=posted_before,
            max_results=max_results,
        )
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEvents'
        assert params['FinancialEventGroupId'] == financial_event_group_id
        assert params['AmazonOrderId'] == amazon_order_id
        assert params['PostedAfter'] == posted_after_stamp
        assert params['PostedBefore'] == posted_before_stamp
        assert params['MaxResultsPerPage'] == str(max_results)

    def test_list_financial_events_by_next_token(self):
        """
        ListFinancialEventsByNextToken operation, via method decorator.<commit_msg>Assertion fail on max_results<commit_after>"""
Tests for the Finances API class.
"""
import unittest
import datetime
import mws
from .utils import CommonRequestTestTools


class FinancesTestCase(unittest.TestCase, CommonRequestTestTools):
    """
    Test cases for Finances.
    """
    # TODO: Add remaining methods for Finances
    def setUp(self):
        self.api = mws.Finances(
            self.CREDENTIAL_ACCESS,
            self.CREDENTIAL_SECRET,
            self.CREDENTIAL_ACCOUNT,
            auth_token=self.CREDENTIAL_TOKEN
        )
        self.api._test_request_params = True

    def test_list_financial_event_groups(self):
        """
        ListFinancialEventGroups operation.
        """
        created_after = datetime.datetime.utcnow()
        created_after_stamp = created_after.isoformat()
        created_before = datetime.datetime.utcnow()
        created_before_stamp = created_before.isoformat()
        max_results = 659
        params = self.api.list_financial_event_groups(
            created_after=created_after,
            created_before=created_before,
            max_results=max_results,
        )
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEventGroups'
        assert params['FinancialEventGroupStartedAfter'] == created_after_stamp
        assert params['FinancialEventGroupStartedBefore'] == created_before_stamp
        assert params['MaxResultsPerPage'] == max_results

    def test_list_financial_event_groups_by_next_token(self):
        """
        ListFinancialEventGroupsByNextToken operation, via method decorator.
        """
        next_token = '<PASSWORD>'
        params = self.api.list_financial_event_groups(next_token=next_token)
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEventGroupsByNextToken'
        assert params['NextToken'] == next_token

    def test_list_financial_event_groups_by_next_token_alias(self):
        """
        ListFinancialEventGroupsByNextToken operation, via alias method.
        """
        next_token = '<PASSWORD>'
        params = self.api.list_financial_event_groups_by_next_token(next_token)
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEventGroupsByNextToken'
        assert params['NextToken'] == next_token

    def test_list_financial_events(self):
        """
        ListFinancialEvents operation.
        """
        posted_after = datetime.datetime.utcnow()
        posted_after_stamp = posted_after.isoformat()
        posted_before = datetime.datetime.utcnow()
        posted_before_stamp = posted_before.isoformat()
        amazon_order_id = '123-4567890-1234567'
        financial_event_group_id = '22YgYW55IGNhcm5hbCBwbGVhEXAMPLE'
        max_results = 156
        params = self.api.list_financial_events(
            financial_event_group_id=financial_event_group_id,
            amazon_order_id=amazon_order_id,
            posted_after=posted_after,
            posted_before=posted_before,
            max_results=max_results,
        )
        self.assert_common_params(params)
        assert params['Action'] == 'ListFinancialEvents'
        assert params['FinancialEventGroupId'] == financial_event_group_id
        assert params['AmazonOrderId'] == amazon_order_id
        assert params['PostedAfter'] == posted_after_stamp
        assert params['PostedBefore'] == posted_before_stamp
        assert params['MaxResultsPerPage'] == max_results

    def test_list_financial_events_by_next_token(self):
        """
        ListFinancialEventsByNextToken operation, via method decorator.
{'fraction_non_alphanumeric': 0.08053875755909841, 'fraction_numerical': 0.007696536558548653, 'mean_word_length': 3.115950226244344, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3854866', 'n_tokens_mistral': 2096, 'n_tokens_neox': 2009, 'n_words': 320}