def test_add_two_currencies(): one_dollar = Currency('USD', 1) two_dollars = Currency('USD', 2) result = one_dollar + two_dollars assert result.value == 3 assert result.currency_type == 'USD' assert isinstance(result, Currency)
def load_from_db(self, nickname): sql_data = {'nickname': nickname} sql_query = """SELECT id, role, nickname, email, password, banned, description FROM user WHERE nickname=%(nickname)s""" with self.connect: cur = self.connect.cursor() cur.execute(sql_query, sql_data) result = cur.fetchone() if not result: return False user = UserFactory.create_user(result) achievements = Achievement.load_from_db(user.user_id, self.connect) user.achievements = {} for achievement in achievements: user.achievements[achievement[1]] = Achievement( achievement[1], achievement[0]) currencies = Currency.load_from_db(user.user_id, self.connect) user.currency = {} for currency in currencies: user.currency[currency[2]] = Currency(currency[2], currency[0], currency[1]) progresses = Progress.load_from_db(user.user_id, self.connect) user.progresses = {} for progress in progresses: user.progresses[progress[0]] = Progress(progress[0], progress[1], progress[2], progress[3]) return user
def register(self, confirm_pass): if self.is_value_exists(self.nickname, 'nickname'): print('{} can\'t register. Username already exists'.format( self.__class__.__name__)) elif self.is_value_exists(self.email, 'email'): print('{} can\'t register. Email already exists'.format( self.__class__.__name__)) elif self.password != confirm_pass: print('Confirmed password isn\'t correct') else: print('{} successfully registered'.format(self.__class__.__name__)) self.currency = { Currency.GOLD_ID: Currency(Currency.GOLD_ID, 'Gold', value=0), Currency.SILVER_ID: Currency(Currency.SILVER_ID, 'Silver', value=50), Currency.BRONZE_ID: Currency(Currency.BRONZE_ID, 'Bronze'), } self.progresses = { Progress.EXPERIENCE_ID: Progress(Progress.EXPERIENCE_ID, 'Experience'), Progress.SOME_PROGRESS_ID: Progress(Progress.SOME_PROGRESS_ID, 'Some_Progress2'), } self.achievements = {} self.save_to_db()
def __init__(self): self.client = zulip.Client(site="https://fazeup.zulipchat.com/api/") self.subscribe_all() self.hacknews = Hackernews() self.trans = Translate() self.movie = Movie() self.lyrics = Lyrics() self.holiday = Holiday() self.currency = Currency() self.cricket = Cricket() # self.chatbot.train("chatterbot.corpus.english") self.crypto = Crypto() self.trans = Translate() self.g = Giphy() self.w = WikiPedia() # self.tw = Twimega() # self.motivate = Motivate() self.shortenedurl = Urlshortener() self.geo = Geocode() self.weather = Weather() self.dict_ = Dictionary() self.joke = Joke() self.pnr = Pnr() self.mustread = Mustread() self.ss = Ss() self.cricket = Cricket() self.poll = Poll() print("done init") self.subkeys = [ "crypto", "translate", "define", "joke", "weather", "giphy", "pnr", "mustread", "poll", "hackernews", "hn", "HN", "motivate", "twitter", "screenshot", "memo", "cricnews", "help", "shorturl", "movie", "currency", "holiday", "lyrics" ]
def test_conversion(): dict_rates = {'USD': 1.0, 'EUR': 0.94, 'GBP': 0.80} c = CurrencyConverter(dict_rates) assert c.convert(a, "USD") == Currency("5.00", "USD") assert c.convert(d, "EUR") == Currency(0.94, "EUR") assert c.convert(i, "USD") == Currency(1, "USD") assert c.convert(j, "USD") != Currency(1, "USD")
def Init(): """ [Required] Initialize Data (Only called on load) """ # settings initialization global settings settings = MySettings(config_file) settings.save() # database initialization global currency, db db = InstancedDatabase(database_file) currency = Currency(Parent, db, settings.name, settings.frequency * 60, settings.quantity) currency.only_subs = settings.only_subs currency.exclude_users = settings.exclude_users # streamlabs notifies global streamlabs_api streamlabs_api = SLNotifies(Parent, currency, settings.streamlabs_bits) if settings.streamlabs_apikey: streamlabs_api.connect(settings.streamlabs_apikey) # loot initialization global loot loot = Loot(Parent, db) return
def test_new_currency(self): currency = Currency('EURUSD', '2003-5', '2006-5') while True: data = currency.get_data() if data == False: break print(data)
def __init__(self): Currency.__init__(self) self.Add("BTC", "Bitcoin", 0) self.Add("MNC", "MinCoin", 1) self.Add("LTC", "Litecoin", 1) self.Add("SC", "SolidCoin", 1) self.Add("DVC", "Devcoin", 1) self.Add("WDC", "WorldCoin", 1)
def __init__(self, cli_data, cache, ver, user, symbol, amount, price): super().__init__() self.ver = ver self.cli_data = cli_data self.cache = cache self.user = user self.symbol = symbol self.amount = Currency(amount) self.price = Currency(price) self.stopevent = threading.Event()
def parse_currency(self, row_element_by_css_selector): currency = Currency() currency.title = row_element_by_css_selector.find_element_by_css_selector( 'th').text currency.sell = row_element_by_css_selector.find_element_by_css_selector( 'td:nth-child(2) span > span').text currency.buy = row_element_by_css_selector.find_element_by_css_selector( 'td:nth-child(3) span > span').text return currency
def __init__(self): self.money = 100000 self.account = Account( self.money ) self.currency_string = 'EURUSD' self.currency = Currency( self.currency_string , '2001-1' , '2001-2' ) self.minute = 240 self.multiple = 3 self.main() self.print_hold_record() self.print_order() self.print_earn()
def test_currency_equivalence_to_zero(): zero_bound1 = Currency(0.0) zero_bound2 = Currency(0) assert zero_bound1.dollars == 0 assert zero_bound1.cents == 0 assert zero_bound1 == 0.0 assert zero_bound1 == 0 assert zero_bound1 == zero_bound2 assert isinstance(zero_bound1.dollars, int) assert isinstance(zero_bound1.cents, int) assert str(zero_bound1) == "0.00" assert float(zero_bound1) == 0.0 assert -0.01 < zero_bound1 < 0.01
def change_year(self): if self.now_year != self.last_year + 1: str_now = str(self.now_year) if self.now_year != 2016: self.EURUSD = Currency('EURUSD', str_now + '-1', str_now + '-12') else: self.EURUSD = Currency('EURUSD', str_now + '-1', str_now + '-7') self.now_year += 1 return True else: return False
def test_recognize_symbols(): currency1 = ('$15.67') assert Currency.money_identifier(currency1) == (15.67, 'USD') currency2 = ('€23.23') assert Currency.money_identifier(currency2) == (23.23, 'EUR') currency3 = ('¥123.45') assert Currency.money_identifier(currency3) == (123.45, 'JPY') # currency2 = Currency(20, 'EUR') # currency3 = Currency(99, 'JPY') "€ ¥ ç"
def test_currency_equivalence_low_positive(): pos_low_bound1 = Currency(0.01) pos_low_bound2 = Currency(1) pos_low_bound3 = Currency("0.01") assert pos_low_bound1.dollars == 0 assert pos_low_bound1.cents == 1 assert pos_low_bound1 == 0.01 assert pos_low_bound2 == pos_low_bound1 + 0.99 assert pos_low_bound1 == pos_low_bound3 assert pos_low_bound1 != pos_low_bound2 assert isinstance(pos_low_bound1.dollars, int) assert isinstance(pos_low_bound1.cents, int) assert str(pos_low_bound1) == "0.01" assert float(pos_low_bound1) == 0.01 assert 0.0 < pos_low_bound1 < 0.02
def test_currency_equivalence_negative(): neg_low_bound1 = Currency(-0.01) neg_low_bound2 = Currency(-1) neg_low_bound3 = Currency("-0.01") assert neg_low_bound1.dollars == 0 assert neg_low_bound1.cents == -1 assert neg_low_bound1 == -0.01 assert neg_low_bound2 == neg_low_bound1 - 0.99 assert neg_low_bound1 == neg_low_bound3 assert neg_low_bound1 != neg_low_bound2 assert isinstance(neg_low_bound1.dollars, int) assert isinstance(neg_low_bound1.cents, int) assert str(neg_low_bound1) == "-0.01" assert float(neg_low_bound1) == -0.01 assert 0.0 > neg_low_bound1 > -0.02
def __init__(self): self.client = zulip.Client(site="https://technh.zulipchat.com/api/", api_key="vkEQgQYDPUgAGmXaTXdMPsMwlkkgMfM5", email="*****@*****.**") self.subscribe_all() self.hacknews = Hackernews() self.trans = Translate() self.movie= Movie() self.lyrics = Lyrics() self.holiday = Holiday() self.currency = Currency() self.cricket = Cricket() self.github = GitHub() self.chatbot = ChatBot(name="technehru") print("done init") self.subkeys = ["use", "help", "translate", "hackernews", "hn", "hotel", "HN", "cricnews", "cricketnews", "movie", "currency", "holiday", "lyrics", "github"]
def load_from_db(self, nickname): sql_data = { 'nickname': nickname } sql_query = """SELECT id, role, nickname, email, password, banned, description FROM user WHERE nickname=%(nickname)s""" with self.connect: cur = self.connect.cursor() cur.execute(sql_query, sql_data) result = cur.fetchone() if not result: return False user = UserFactory.create_user(result) achievements = Achievement.load_from_db(user.user_id, self.connect) user.achievements = {} for achievement in achievements: user.achievements[achievement[1]] = Achievement(achievement[1], achievement[0]) currencies = Currency.load_from_db(user.user_id, self.connect) user.currency = {} for currency in currencies: user.currency[currency[2]] = Currency(currency[2], currency[0], currency[1]) progresses = Progress.load_from_db(user.user_id, self.connect) user.progresses = {} for progress in progresses: user.progresses[progress[0]] = Progress(progress[0], progress[1], progress[2], progress[3]) return user
def check_money(self, user): try: account = self.get_current_funds(user) except KeyError: response = self.new_user(user) account = Currency(0.0) return account
def value2object(value, stringtypes): if value is None: return None if stringtypes == "int": return int(value) elif stringtypes == "float": return float(value) elif stringtypes == "Decimal": return Decimal(value) elif stringtypes == ["datetime", "date", "time"]: return value elif stringtypes in ["EUR", "USD"]: try: from currency import Currency return Currency(value, "EUR") except ImportError: raise NotImplementedError( "You need https://github.com/turulomio/reusingcode/python/currency.py to use this function." ) elif stringtypes == "Percentage": try: from percentage import Percentage return Percentage(value, 1) except ImportError: raise NotImplementedError( "You need https://github.com/turulomio/reusingcode/python/currency.py to use this function." ) return value
def __init__(self): self.client = zulip.Client(site="https://myra.zulipchat.com/api/") self.subscribe_all() self.hacknews = Hackernews() self.trans = Translate() self.movie = Movie() self.lyrics = Lyrics() self.holiday = Holiday() self.currency = Currency() self.cricket = Cricket() print("done init") self.subkeys = [ "translate", "hackernews", "hn", "hotel", "HN", "askme", "cricnews", "movie", "currency", "holiday", "lyrics" ]
def convert(self, currency_obj, code_to_convert): if currency_obj.code in self.dict_rates and code_to_convert in self.dict_rates: return Currency( currency_obj.amount * (self.dict_rates[code_to_convert]) / self.dict_rates[currency_obj.code], code_to_convert) else: raise UnknownCurrencyCodeError
class TestCurrency(TestCase): def setUp(self): self.__server = MockServer() self.__currency = Currency(self.__server, 'XAU_USD') def testHistory(self): """Test normal history retrieval from a server and verify intended order of values.""" history = self.__currency.history('5s', 1) self.assertEqual(len(history), 1) self.assertEqual(history[0]['time'], datetime(2014, 7, 12, 22, 25, 15)) history = self.__currency.history('5s', 2) self.assertEqual(len(history), 2) self.assertEqual(history[0]['time'], datetime(2014, 7, 12, 22, 25, 15)) self.assertEqual(history[1]['time'], datetime(2014, 7, 12, 22, 25, 10))
def convert(self, other, conversion_unit): if other.code in self.rates and conversion_unit in self.rates: new_amount = (other.amount * self.rates[conversion_unit]) / self.rates[other.code] return Currency(round(new_amount, 2), conversion_unit) else: raise UnknownCurrencyCodeError
def convert(self, from_currency, to_currency_code): try: rate = (self.conversion_dict[to_currency_code] / self.conversion_dict[from_currency.currency_code]) raw_value = rate * from_currency.value rounded_value = round(raw_value, 2) return Currency(to_currency_code, rounded_value) except: raise UnkownCurrencyCodeError()
def process_currency(raw_json, currency_to_process): currency_info = raw_json[currency_to_process] return Currency( currency_to_process, "Updated: " + currency_info[BUY_RATE_KEY][DATE_KEY], fixed_digits(float(currency_info[BUY_RATE_KEY][RATE_KEY])), fixed_digits(float(currency_info[SELL_RATE_KEY][RATE_KEY])))
def test_currency_json_encoding(): import json unencoded = Currency(12.34) user_dict = {"acc": unencoded, "stk": 34.56, "empty_list": []} assert json.dumps( user_dict, cls=Currency) == '{"acc": 12.34, "stk": 34.56, "empty_list": []}'
def __init__(self): self.money = 100000 self.account = Account(self.money) self.account.set_stop(0, 10000) self.currency_string = 'EURUSD' self.currency = Currency(self.currency_string, '2015-1', '2015-2') self.multiple = 10 self.main() print_earn(self.account)
def returnable(self, amount): for currency in Currency.items(): div = int(amount / currency.value) if div == 0: continue else: amount -= currency.value * min(div, self.__currencies[currency]) return amount == 0
def value2object(value, stringtypes): if value is None: return None if stringtypes == "int": return int(value) elif stringtypes == "float": return float(value) elif stringtypes == "Decimal": return Decimal(value) elif stringtypes == ["datetime", "date", "time"]: return value elif stringtypes in ["EUR", "€"]: return Currency(value, "EUR") elif stringtypes in ["USD", "$"]: return Currency(value, "EUR") elif stringtypes == "Percentage": return Percentage(value, 1) return value
def quote(self, symbol, user): val = [] try: response = requests.get( f"{self.quote_cache_server_url}/{QuoteCacheUrls.GET_QUOTE}/{symbol}" ).json() if (response["status"] != "SUCCESS" or (time.time() - float(response["data"]["quote_time"])) >= 60): val = self.new_quote(symbol, user) else: data = response["data"] quote_time = data["quote_time"] quote_amount = Currency(data["dollars"]) + Currency( data["cents"]) cryptokey = data["cryptokey"] val = [quote_amount, symbol, user, quote_time, cryptokey] except KeyError as e: val = self.new_quote(symbol, user) return val
def __init__(self): self.money = 100000 self.account = Account( self.money ) self.account.set_stop(10000,2000) self.currency_string = 'EURUSD' self.currency = Currency( self.currency_string , '2015-1' , '2016-3' ) self.multiple = 3 self.minute = 600 self.main() print_earn( self.account )
def test_replace_symbol_with_currency_code(): curr1 = '$1.20' curr2 = '€1.20' curr3 = '¥1.20' assert Currency(Currency.separate_symbol_and_amount(curr1)), Currency(Currency.assign_currency_code_to_symbol(curr1)) == Currency(1.20, 'USD') assert Currency(Currency.separate_symbol_and_amount(curr2)), Currency(Currency.assign_currency_code_to_symbol(curr2)) == Currency(1.20, 'EUR') assert Currency(Currency.separate_symbol_and_amount(curr3)), Currency(Currency.assign_currency_code_to_symbol(curr3)) == Currency(1.20, 'JPY')
def test_replace_symbol_with_currency_code(): currency1 = '$5.65' currency2 = '€5.65' currency3 = '¥5.65' assert Currency(Currency.take_symbol_off_amount(currency1), Currency.assign_currency_code_for_symbol(currency1)) == Currency(5.65, 'USD') assert Currency(Currency.take_symbol_off_amount(currency2), Currency.assign_currency_code_for_symbol(currency2)) == Currency(5.65, 'EUR') assert Currency(Currency.take_symbol_off_amount(currency3), Currency.assign_currency_code_for_symbol(currency3)) == Currency(5.65, 'JPY')
def widget_balance(self): acclen = len(self.statement.Accounts) w = Widget(u"Баланс", cx=acclen + 3, cy=3) self.widgets.append(w) rowscount = len(self.statement.Rows) accts = {} w.cells[0][0] = "Total" w.cells[1][0] = self.statement.Rows[rowscount - 1].left_pool # hitc=0 lastrow = self.statement.Rows[rowscount - 1] for ref in self.statement.Accounts: v = lastrow.cumulatives[ref.name] accts[ref.name] = self.AccInfo(ref) accts[ref.name].balance = v coli = 2 w.cells[1][1] = "balance" w.cells[2][1] = "available" w.cells[2][0] = 0.0 w.totalAvailable = 0.0 for acc2 in self.statement.Accounts: w.cells[0][coli] = acc2.name # if accts.has_key(acc2.name): acc = accts[acc2.name] # if acc.ref: bal = acc.balance limit = acc2.limit avail = bal if limit != 0: limit = Currency.convert(acc2.currency, self.statement.currency, self.moment, limit) avail = bal - limit print acc2.name, limit, bal, avail w.cells[1][coli] = bal w.cells[2][coli] = avail w.totalAvailable += bal - limit coli += 1 w.cells[2][0] = w.totalAvailable return w
def test_bad1(self): self.money = Currency.check_currency("09534.2343490578245") correct_money = 9534.23 self.assertEqual( correct_money, self.money)
def test_bad2(self): self.money = Currency.check_currency("%£353") correct_money = 353.00 self.assertEqual( correct_money, self.money)
from currency import Currency from datetime import datetime currency = Currency('2016-04-07', 'USD', ['MXN', 'EUR']) c = currency.fetch() print(c)
def do_print(self,st): ws=self.ws style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on', num_format_str='#,##0.00') #style_time1 = xlwt.easyxf(num_format_str='D-MMM-YY') style_time1 = xlwt.easyxf(num_format_str='D-MMM') style_money_red=xlwt.easyxf('font: bold on, color-index red',num_format_str='#,##0.00') style_text_red=xlwt.easyxf('font: color-index red',num_format_str='#,##0.00') style_text_green=xlwt.easyxf('font: color-index green',num_format_str='#,##0.00') #ws = self.wb.add_sheet('Txs') ws.col(5).width=256*40 ws.col(0).width=256*8 ws.col(1).width=256*6 ws.col(2).width=256*6 ws.col(3).width=256*10 ws.col(4).width=256*10 #ws.set_panes_frozen(True) ws.panes_frozen = True ws.horz_split_pos = 1 ws.vert_split_pos = 1 ws.normal_magn=70 for ci in range(6,12): ws.col(ci).width=256*12 ws.col(13).width=256*14 ri=0 #ri+=1 bc=0 acc_col_idx={} #acc_last_left={} acc_last_left_knownletover={} t=0 for acc in st.Accounts: acc_col_idx[acc.name]= t #acc_last_left[acc.name]=Money(0) acc_last_left_knownletover[acc.name]=False ws.write(ri, bc+6+t, acc.name) t+=1 ws.write(ri, bc+6+t, "Pool") #start of period ri+=1 for row in st.Rows: #надо учитывать остатки даже за пределами диапазаон времени, иначе неконсистенность в цифрах if row.account: accname=row.account.name #acc_last_left[accname]=row.left_acc acc_last_left_knownletover[accname]= (row.type==RowType.LeftOver) if row.date>self._end or row.date<self._start: continue descr_col_ind=bc+5 if row.type==RowType.Lost: #style=style_money_red ws.write(ri, bc+0, row.date,style_time1) ws.write(ri, bc+1, row.account.name) ws.write(ri,descr_col_ind, row.description, style_text_red) ri+=1 continue if row.type==RowType.Transition: trans=row.tx ws.write(ri, bc+0, row.date,style_time1) ws.write(ri, descr_col_ind, row.description,style_text_green) accs=[trans.tx_from_obj.account.name,trans.tx_to_obj.account.name] self.print_accounts_lefts(st,ws,ri,descr_col_ind,accs,False,acc_col_idx,row.cumulatives) ws.write(ri, descr_col_ind+1+t, row.left_pool,self.style_money) ri+=1 continue amount_col_index=bc+3 if row.type==RowType.Tx: if row.tx.direction==1: #income amount_col_index=bc+4 self.print_accounts_lefts(st,ws,ri,descr_col_ind,[accname],row.type==RowType.LeftOver,acc_col_idx,row.cumulatives) #ws.write(ri, bc+5+this_acc_col_idx, accleft,style_money) ws.write(ri, bc+0, row.date,style_time1) ws.write(ri, bc+1, accname) if row.type!=RowType.LeftOver: ws.write(ri, amount_col_index, row.amount.as_float(),self.style_money) ws.write(ri, descr_col_ind, row.description) rate=Currency.getrate(row.date,row.tx.account.currency, st.currency) if row.type==RowType.Tx: if row.tx.original_currency!=None: if row.tx.original_currency!=st.currency: if row.tx.original_amount==0: raise Exception("row.tx.original_amount==0 in {0}".format(row.tx._txid)) rate=row.tx._amount/row.tx.original_amount ws.write(ri,bc+2,rate.as_float(),self.style_money) pool_known_leftover=True for acc in st.Accounts: latval=row.cumulatives[acc.name] vt=acc_last_left_knownletover[acc.name] if not latval==0: pool_known_leftover=(pool_known_leftover and vt) if pool_known_leftover: ws.write(ri, descr_col_ind+1+t, row.left_pool,self.style_money_bold) else: ws.write(ri, descr_col_ind+1+t, row.left_pool,self.style_money) srcinfoi=descr_col_ind+1+t+1 src=row.tx.src if src: ws.write(ri,srcinfoi, row.tx.src.verbose()) ws.write(ri,srcinfoi+1, row.tx.get_id()) if row.type==RowType.Tx: stags="" for t1 in row.tags: if len(stags)>0: stags+=", " stags+=t1 ws.write(ri,srcinfoi+2, stags) if hasattr(row, 'classification'): ws.write(ri,srcinfoi+3, row.classification.title) ri+=1
def test_good4(self): self.money = Currency.check_currency("5362907888969") correct_money = 5.362907888969e+12 self.assertEqual( correct_money, self.money)
def setUp(self): self.money = Currency.check_currency("")
def test_good5(self): self.money = Currency.check_currency("35532") correct_money = 35532.00 self.assertEqual( correct_money, self.money)
def test_vbad0(self): self.money = Currency.check_currency("thirte") correct_money = 0.0 self.assertEqual( correct_money, self.money)
def read(self, filename, sheetname): print " budget",filename book = xlrd.open_workbook(filename) sheet=book.sheet_by_name(sheetname) #expectation behavemap={"expectation":BudgetBehaviour.Expectation, "done":BudgetBehaviour.Done} periodsmap={"monthly":BudgetFreq.Monthly,"weekly":BudgetFreq.Weekly,"annually": BudgetFreq.Annually,"onetime": BudgetFreq.OneTime, "daily": BudgetFreq.Daily} for rowi in range(1,sheet.nrows): r=sheet.row(rowi) speriod=r[1].value.lower() sday=r[2].value day=1 exactdate=None if isinstance(sday, float): if sday>31: xlsdate=sday tdate=xlrd.xldate_as_tuple(xlsdate,0) exactdate=datetime(tdate[0],tdate[1],tdate[2]) else: day=int(sday) if len(speriod)<1 and exactdate: speriod="onetime" if len(speriod)<1: continue if not periodsmap.has_key(speriod): raise Exception("Unknown Period '{0}' at row {1}".format(speriod, rowi)) period=periodsmap[speriod] scur=r[9].value.upper().strip() currency=rub if len(scur)>0: currency, cur_index=Currency.str_to_currency_code(scur) sbehave=r[10].value.lower().strip() behave=BudgetBehaviour.Std if len(sbehave)>0: behave=behavemap[sbehave] saccomplished="" if len(r)>11: saccomplished=r[11].value tags=r[6].value.split(',') etags=[] for t in tags: st=t.strip() if len(st)>0: etags.append(st) tags=etags debit=r[3].value if not isinstance(debit, float): debit=0 credit=r[4].value if not isinstance(credit, float): credit=0 descr=r[5].value if period==BudgetFreq.OneTime: if not exactdate: mes=u"Exact date for budget line '{0}' missed".format(descr) print mes raise Exception(mes) id=r[0].value br=BudgetRow(period,day, debit,credit,currency,tags,descr,id,saccomplished,exactdate=exactdate,behaviour=behave) self.Add(br) br.start=self.xsldate(r[7].value) br.end=self.xsldate(r[8].value)
def test_middle3(self): self.money = Currency.check_currency("460.085634") correct_money = 460.09 self.assertEqual( correct_money, self.money)
def test_good6(self): self.money = Currency.check_currency("352.46") correct_money = 352.46 self.assertEqual( correct_money, self.money)
from currency import Currency print("\t-----------------------------------------------------") print("\tWELCOME TO TEST BED FOR PROJ 10 - CURRENCY CONVERSION") print("\t-----------------------------------------------------") print("------------------------------------------------------------------------------------") print("TC1: Create a new valid currency type and print it") curr1 = Currency(100, 'USD') print(curr1) print("------------------------------------------------------------------------------------") print("TC2: Create a new invalid currency type and print it") curr1 = Currency(200, 'xyz') print(curr1) print("------------------------------------------------------------------------------------") print("TC3: Convert a currency to another and print both") curr1 = Currency(200, 'USD') curr2 = curr1.convert_to('SEK') print(curr1) print(curr2) print("------------------------------------------------------------------------------------") print("TC4: Adding two currency amounts") curr1 = Currency(100, 'USD') curr2 = Currency(1316, 'SEK') print(curr1+curr2) print("------------------------------------------------------------------------------------") print("TC5: Adding a currency amount and an int")