def test_Unicode(self): unicode_comment = '日本語入力' self.transaction.comments['Unicode'] = Comment( comment_value=unicode_comment) transaction = self.transactions_interface.new(self.transaction) self.assertEqual( transaction.comments.get('Unicode').comment_value, unicode_comment)
def generate_wine(asset_manager_id=None, asset_id=None): props = generate_common(asset_manager_id=asset_manager_id, asset_id=asset_id) wine = Wine(year=random_date(start_year=1950, end_year=2016), producer=random_string(5), region=random.choice(['Bordeaux', 'Burgundy', 'Tuscany', 'Napa Valley']), appellation=random.choice([None]*3 + ['Côtes du Rhône', 'Graves', 'Saint-Émilion']), classification=random.choice(list(WINE_CLASSIFICATIONS)), color=random.choice(['Red', 'White']), bottle_size=random.choice(['0.75L']*3 + ['1.5L']), bottle_in_cellar=random.choice([True]*3 + [False]), bottle_location=random_string(20), storage_cost=None, rating_type='Parker', rating_value=random.randint(93, 100), packing_type=random.choice(list(WINE_PACKING_TYPE)), to_drink_start=random_date(start_year=2000), to_drink_end=random_date(end_year=2050), comments = {'DrinkingNotes': Comment(comment_value=random_string(100))}, **props) return wine
def generate_transaction(asset_manager_id=None, asset_book_id=None, counterparty_book_id=None, asset_id=None, quantity=None, transaction_date=None, transaction_id=None, price=None, transaction_action=None, transaction_type=None, settlement_date=None, transaction_status=None, transaction_currency=None, settlement_currency=None, net_affecting_charges=None, charge_currency=None): # Explicitly handle price is None (in case price is 0) price = Decimal(random.uniform(1.0, 1000.0)).quantize( Decimal('0.01')) if price is None else price transaction_currency = transaction_currency or random.choice( ['SGD', 'USD']) settlement_currency = settlement_currency or transaction_currency or random.choice( ['SGD', 'USD']) common = generate_common(asset_manager_id=asset_manager_id, asset_book_id=asset_book_id, counterparty_book_id=counterparty_book_id, asset_id=asset_id, quantity=quantity, transaction_date=transaction_date, transaction_id=transaction_id, transaction_action=transaction_action, transaction_status=transaction_status, transaction_type=transaction_type, settlement_date=settlement_date) transaction = Transaction(price=price, transaction_currency=transaction_currency, settlement_currency=settlement_currency, **common) charges = { charge_type: Charge(charge_value=Decimal(random.uniform(1.0, 100.0)).quantize( Decimal('0.01')), currency=charge_currency or random.choice(['USD', 'SGD']), net_affecting=net_affecting_charges or random.choice([True, False])) for charge_type in CHARGE_TYPES } links = { 'Single': Link(linked_transaction_id=random_string(8)), 'Multiple': {Link(linked_transaction_id=random_string(8)) for x in range(3)} } codes = { code_type: Code(code_value=random_string(8)) for code_type in CODE_TYPES } comments = { comment_type: Comment(comment_value=random_string(8)) for comment_type in COMMENT_TYPES } parties = { party_type: Party(party_id=random_string(8)) for party_type in PARTY_TYPES } rates = { rate_type: Rate(rate_value=Decimal(random.uniform(1.0, 100.0)).quantize( Decimal('0.01'))) for rate_type in RATE_TYPES } references = { ref_type: Reference(reference_value=random_string(10)) for ref_type in REFERENCE_TYPES } transaction.charges.update(charges) transaction.codes.update(codes) transaction.comments.update(comments) transaction.links.update(links) transaction.parties.update(parties) transaction.rates.update(rates) transaction.references.update(references) return transaction