peshay / btcde

A Python Module for Bitcoin.de Trading API
MIT License
38 stars 24 forks source link

Add tests for float vs decimal #19

Closed peshay closed 6 years ago

peshay commented 6 years ago

As there are differences between float and decimal calculation, a test should be added which would have an incorrect calculation only for floats.

peshay commented 6 years ago

For example: make a test with mocked response for show_orderbook('buy'), that returns a float value and then add another fload/decimal to that value and see if it returns the correct value. for example

params = {'type': 'buy',
        'trading_pair': 'btceur',
        'max_amount': 10,
        'price': 1337}
response = self.sampleData('showOrderbook_buy')
m.get(requests_mock.ANY, json=response, status_code=200)
data = self.conn.showOrderbook(params.get('type'),
            params.get('trading_pair'),
            price=params.get('price'))
assertEqual(data.get('price') + decimal(22.3), decimal(2232.2))
assertNotEqual(data.get('price') +22.3, 2232.2)

Something like this... I am not so experience on the usage of the package decimal

peshay commented 6 years ago

eaf0651bb51ed8e9bb44e3e230d24df1329debca