11import datetime
22from unittest import TestCase
3- from forex_python .bitcoin import BtcConverter
3+ from forex_python .bitcoin import *
44
55
66class TestCommon (TestCase ):
@@ -11,112 +11,112 @@ def setUp(self):
1111 self .b = BtcConverter ()
1212
1313
14- class TestLatestPrice (TestCommon ):
14+ class TestLatestPrice (TestCase ):
1515 """
1616 Test get latest price using currency code
1717 """
1818 def test_latest_price_valid_currency (self ):
19- price = self . b . get_latest_price ('USD' )
19+ price = get_latest_price ('USD' )
2020 self .assertEqual (type (price ), float )
2121
2222 def test_latest_price_invalid_currency (self ):
23- price = self . b . get_latest_price ('XYZ' )
23+ price = get_latest_price ('XYZ' )
2424 self .assertFalse (price )
2525
2626
27- class TestPreviousPrice (TestCommon ):
27+ class TestPreviousPrice (TestCase ):
2828 """
2929 Test Price with date input
3030 """
3131 def test_previous_price_valid_currency (self ):
3232 date_obj = datetime .datetime .today () - datetime .timedelta (days = 15 )
33- price = self . b . get_previous_price ('USD' , date_obj )
33+ price = get_previous_price ('USD' , date_obj )
3434 self .assertEqual (type (price ), float )
3535
3636 def test_previous_price_invalid_currency (self ):
3737 date_obj = datetime .datetime .today () - datetime .timedelta (days = 15 )
38- price = self . b . get_previous_price ('XYZ' , date_obj )
38+ price = get_previous_price ('XYZ' , date_obj )
3939 self .assertFalse (price )
4040
4141
42- class TestPreviousPriceList (TestCommon ):
42+ class TestPreviousPriceList (TestCase ):
4343 """
4444 Test previous price list for a currency
4545 """
4646 def test_previous_price_list_with_valid_currency (self ):
4747 start_date = datetime .datetime .today () - datetime .timedelta (days = 15 )
4848 end_date = datetime .datetime .today ()
49- price_list = self . b . get_previous_price_list ('USD' , start_date , end_date )
49+ price_list = get_previous_price_list ('USD' , start_date , end_date )
5050 self .assertTrue (price_list )
5151 self .assertEqual (type (price_list ), dict )
5252
5353 def test_previous_price_list_with_invalid_currency (self ):
5454 start_date = datetime .datetime .today () - datetime .timedelta (days = 15 )
5555 end_date = datetime .datetime .today ()
56- price_list = self . b . get_previous_price_list ('XYZ' , start_date , end_date )
56+ price_list = get_previous_price_list ('XYZ' , start_date , end_date )
5757 self .assertFalse (price_list )
5858 self .assertEqual (type (price_list ), dict )
5959
6060
61- class TestConvertBtc (TestCommon ):
61+ class TestConvertBtc (TestCase ):
6262 """
6363 Test Converting amount to Bit coins
6464 """
6565 def test_convet_to_btc_with_valid_currency (self ):
66- coins = self . b . convert_to_btc (250 , 'USD' )
66+ coins = convert_to_btc (250 , 'USD' )
6767 self .assertEqual (type (coins ), float )
6868
6969 def test_convet_to_btc_with_invalid_currency (self ):
70- coins = self . b . convert_to_btc (250 , 'XYZ' )
70+ coins = convert_to_btc (250 , 'XYZ' )
7171 self .assertFalse (coins )
7272
7373
74- class TestConvertBtcToCur (TestCommon ):
74+ class TestConvertBtcToCur (TestCase ):
7575 """
7676 Convert Bit Coins to Valid Currency amount
7777 """
7878 def test_convert_btc_to_cur_valid_currency (self ):
79- amount = self . b . convert_btc_to_cur (2 , 'USD' )
79+ amount = convert_btc_to_cur (2 , 'USD' )
8080 self .assertEqual (type (amount ), float )
8181
8282 def test_convert_btc_to_cur_invalid_currency (self ):
83- amount = self . b . convert_btc_to_cur (2 , 'XYZ' )
83+ amount = convert_btc_to_cur (2 , 'XYZ' )
8484 self .assertFalse (amount )
8585
8686
87- class TestConvertToBtcOn (TestCommon ):
87+ class TestConvertToBtcOn (TestCase ):
8888 """
8989 Convert To bit coin based on previous dates
9090 """
9191 def test_convert_to_btc_on_with_valid_currency (self ):
9292 date_obj = datetime .datetime .today () - datetime .timedelta (days = 15 )
93- coins = self . b . convert_to_btc_on (300 , 'USD' , date_obj )
93+ coins = convert_to_btc_on (300 , 'USD' , date_obj )
9494 self .assertEqual (type (coins ), float )
9595
9696 def test_convert_to_btc_on_with_invalid_currency (self ):
9797 date_obj = datetime .datetime .today () - datetime .timedelta (days = 15 )
98- coins = self . b . convert_to_btc_on (300 , 'XYZ' , date_obj )
98+ coins = convert_to_btc_on (300 , 'XYZ' , date_obj )
9999 self .assertFalse (coins )
100100
101101
102- class TestConvertBtcToCurOn (TestCommon ):
102+ class TestConvertBtcToCurOn (TestCase ):
103103 """
104104 Convert BitCoins to valid Currency
105105 """
106106 def test_convert_to_btc_on_with_valid_currency (self ):
107107 date_obj = datetime .datetime .today () - datetime .timedelta (days = 15 )
108- amount = self . b . convert_btc_to_cur_on (3 , 'USD' , date_obj )
108+ amount = convert_btc_to_cur_on (3 , 'USD' , date_obj )
109109 self .assertEqual (type (amount ), float )
110110
111111 def test_convert_to_btc_on_with_invalid_currency (self ):
112112 date_obj = datetime .datetime .today () - datetime .timedelta (days = 15 )
113- amount = self . b . convert_btc_to_cur_on (3 , 'XYZ' , date_obj )
113+ amount = convert_btc_to_cur_on (3 , 'XYZ' , date_obj )
114114 self .assertFalse (amount )
115115
116116
117- class TestBitCoinSymbol (TestCommon ):
117+ class TestBitCoinSymbol (TestCase ):
118118 """
119119 Bit Coin symbol
120120 """
121121 def test_bitcoin_symbol (self ):
122- self .assertEqual (self . b . get_symbol (), "\u0E3F " )
122+ self .assertEqual (get_btc_symbol (), "\u0E3F " )
0 commit comments