def order_data(): return { 'id': str(uuid4()), 'sequent_number': str(random.randint(1, 100)), 'amount': rand_formatted_amount(), 'currency': rand_curency(), 'status': random.choice(list(OrderStatus)).name, 'expiration_date': (datetime.utcnow() + timedelta(minutes=random.randint(1, 100))).isoformat(), 'payment_url': rand_str(), 'response_url': rand_str(), 'is_test': random.choice((True, False)), 'details': order_details(), 'payment_transfer': rand_transfer() }
def rand_transfer(): return { 'id': str(uuid4()), 'amount': rand_formatted_amount(), 'currency': rand_curency(), 'sender': rand_str(), 'receiver': rand_str(), 'txn_type': TxnType.ORDER_PAYMENT.name, 'status': TxnStatus.ACCEPTED.name, 'action': rand_action(), 'memo': rand_str() }
def full_input(): return { 'currency_name': random.choice(CURRENCIES), 'currency_smart_contract': 'cash.token', 'amount_to_pay': str(rand_amount()), 'response_url': rand_str(), 'expiration_time': random.randint(10, 40), 'merchant_order_id': rand_str(), 'description': rand_str(), 'success_payment_redirect_url': rand_str(), 'failed_payment_redirect_url': rand_str() }
def rand_action(): return { 'txid': rand_str(), 'block_number': str(random.randint(1, 100)), 'global_sequence': str(random.randint(1, 100)), 'is_irreversible': random.choice((True, False)), 'is_reversed': random.choice((True, False)) }
def min_input(): currency_name, currency_smart = random.choice(CURRENCIES) return { 'currency_name': currency_name, 'currency_smart_contract': currency_smart, 'amount_to_pay': str(rand_amount()), 'response_url': rand_str(), }
def setup(cls): cls.client = BaseClient(str(uuid4()), str(uuid4())) cls.data = order_data() cls.headers = { 'SIGNATURE': hashlib.sha256(rand_str().encode()).hexdigest() }
def test_unexpected_field(full_dict_input): full_dict_input[str(uuid4())] = rand_str() with pytest.raises(AssertionError) as e: CreateOrderInput.from_dict(full_dict_input) assert 'Got unexpected params:' in str(e.value)
def order_details(): return {'merchant_order_id': rand_str(), 'description': rand_str()}
def error_response(): return {'status': 'ERROR', 'error': rand_str()}