├── .travis.yml ├── LICENSE ├── README.md ├── examples └── users.py ├── pyduinocoin ├── __init__.py ├── dict_obj.py ├── exceptions.py └── pyduinocoin.py ├── pyproject.toml ├── setup.py └── tests ├── dict_obj_test.py ├── exceptions_test.py └── pyduinocoin_test.py /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - '3.5' 4 | - '3.6' 5 | - '3.7' 6 | - '3.8' 7 | - '3.9' 8 | - 'nightly' 9 | install: 10 | - pip install -r requirements.txt 11 | script: 12 | - python -m unittest discover tests "*_test.py" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 Sergio Contreras Agustí 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PyDuinoCoin 2 | ![Build Status](https://travis-ci.com/BackrndSource/pyduinocoin.svg?branch=master) 3 | 4 | PyDuinoCoin is a simple python integration for the [DuinoCoin REST API](https://github.com/revoxhere/duco-rest-api), that allows developers to communicate with DuinoCoin Main Server. 5 | 6 | ## Install 7 | 8 | > PyDuinoCoin is available on the Python Package Index (PyPI): 9 | https://pypi.python.org/pypi/pyduinocoin 10 | 11 | You can install PyDuinoCoin using pip. 12 | 13 | ```bash 14 | $ pip install pyduinocoin 15 | ``` 16 | 17 | ### Making queries 18 | 19 | You can use the `DuinoClient` object instance to perform queries. 20 | 21 | Most methods of the `DuinoClient` class have the same name as the REST API endpoints. 22 | 23 | > Check out the REST API Documentation: https://github.com/revoxhere/duco-rest-api 24 | 25 | All responses will return a `DictObj` object or a `list` object. All `dict` objects in the response will be transformed into `DictObj`. You can access to the data of a `DictObj` object as you would with a `dict` object, or do it through the attributes. An example to illustrate this: 26 | 27 | ```python 28 | client = DuinoClient() 29 | response = client.user('example') 30 | 31 | # It is the same:: 32 | for response['balance']['username'] 33 | for response.balance['username'] 34 | for response['balance'].username 35 | for response.balance.username # I love this one 36 | 37 | # DictObj is iterable: 38 | for key, value in response.items(): 39 | print(key) 40 | print(value) 41 | ``` 42 | 43 | ## Examples 44 | 45 | Usage examples can be found in the [/examples](https://github.com/BackrndSource/pyduinocoin/blob/master/examples) folder of the project 46 | 47 | ## Tests 48 | 49 | You can run the tests via the command line. 50 | 51 | Place your terminal at the root of the project and run the following command. 52 | 53 | ```bash 54 | $ python -m unittest discover tests "*_test.py" 55 | ``` 56 | 57 | ## Greetings 58 | 59 | [@revoxhere](https://github.com/revoxhere) by [duco-rest-api](https://github.com/revoxhere/duco-rest-api) for the REST API documented. 60 | [@dansinclair25](https://github.com/dansinclair25) by [duco-rest-api](https://github.com/dansinclair25/duco-rest-api) for the original REST API. 61 | -------------------------------------------------------------------------------- /examples/users.py: -------------------------------------------------------------------------------- 1 | from pyduinocoin import DuinoClient 2 | 3 | client = DuinoClient() 4 | username = '' # Input username 5 | 6 | try: 7 | result = client.user(username) 8 | except Exception as error: 9 | print(error) 10 | else: 11 | print('Balance: ' + str(result.balance.balance)) 12 | 13 | print('Miners: ') 14 | for miner in result.miners: 15 | print(miner) 16 | 17 | print('Transactions: ') 18 | for transaction in result.transactions: 19 | print(transaction) -------------------------------------------------------------------------------- /pyduinocoin/__init__.py: -------------------------------------------------------------------------------- 1 | from .exceptions import PyDuinoCoinException 2 | from .dict_obj import DictObj 3 | from .pyduinocoin import DuinoClient -------------------------------------------------------------------------------- /pyduinocoin/dict_obj.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | class DictObj(): 5 | def __init__(self, entries=None): 6 | if isinstance(entries, dict): 7 | for key, value in entries.items(): 8 | if isinstance(entries[key], list): 9 | value = [DictObj(item) if isinstance(item, dict) else item for item in value] 10 | if isinstance(entries[key], dict): 11 | value = DictObj(value) 12 | setattr(self, ''.join(filter(str.isalnum, key)), value) 13 | 14 | def __delitem__(self, key): 15 | return delattr(self, key) 16 | 17 | def __getitem__(self, key): 18 | return getattr(self, key) 19 | 20 | def __iter__(self): 21 | return iter(self.__dict__) 22 | 23 | def __len__(self): 24 | return len(self.__dict__) 25 | 26 | def __repr__(self): 27 | return '(' + repr(self.__dict__) + ')' 28 | 29 | def __setitem__(self, key, value): 30 | return setattr(self, key, value) 31 | 32 | def __str__(self): 33 | return str(self.__dict__) 34 | 35 | if sys.version_info >= (3, 8): 36 | def __reversed__(self): 37 | return reversed(self.__dict__) 38 | 39 | if sys.version_info >= (3, 9): 40 | def __class_getitem__(self, key): 41 | return self.__dict__.__class_getitem__(key) 42 | 43 | def __ior__(self, value): 44 | return self.__dict__.__ior__(value) 45 | 46 | def __or__(self, value): 47 | return self.__dict__.__or__(value) 48 | 49 | def clear(self): 50 | return self.__dict__.clear() 51 | 52 | def copy(self): 53 | return DictObj(self.__dict__.copy()) 54 | 55 | def fromkeys(self, keys, value=None): 56 | return DictObj(self.__dict__.fromkeys(keys, value)) 57 | 58 | def get(self, key, value=None): 59 | return self.__dict__.get(key, value) 60 | 61 | def items(self): 62 | return self.__dict__.items() 63 | 64 | def keys(self): 65 | return self.__dict__.keys() 66 | 67 | def pop(self, key, value=None): 68 | return self.__dict__.pop(key, value) 69 | 70 | def popitem(self): 71 | return self.__dict__.popitem() 72 | 73 | def setdefault(self, key, value=None): 74 | return self.__dict__.setdefault(key, value) 75 | 76 | def update(self, entries): 77 | return self.__init__(entries) 78 | 79 | def values(self): 80 | return self.__dict__.values() -------------------------------------------------------------------------------- /pyduinocoin/exceptions.py: -------------------------------------------------------------------------------- 1 | class PyDuinoCoinException(Exception): 2 | pass -------------------------------------------------------------------------------- /pyduinocoin/pyduinocoin.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from .exceptions import PyDuinoCoinException 3 | from .dict_obj import DictObj 4 | 5 | 6 | class DuinoClient(): 7 | ''' 8 | API REST documentation: 9 | https://github.com/revoxhere/duco-rest-api 10 | ''' 11 | 12 | def __init__(self): 13 | self._base_url = 'https://server.duinocoin.com/' 14 | 15 | def _get(self, endpoint, params='', results_key='result'): 16 | ''' 17 | ''' 18 | url = '{}{}'.format(self._base_url, endpoint) 19 | response = requests.request("GET", url, params=params) 20 | 21 | if response.status_code == 200: 22 | json = response.json() 23 | 24 | if ('success' in json and json['success'] == False) or 'message' in json: 25 | raise PyDuinoCoinException(json['message'] if 'message' in json else 'Unknown error') 26 | 27 | if results_key: 28 | if isinstance(json[results_key], list): 29 | return [DictObj(item) if isinstance(item, dict) else item for item in json[results_key]] 30 | else: 31 | return DictObj(json[results_key]) 32 | 33 | return DictObj(json) 34 | else: 35 | raise PyDuinoCoinException('SERVER REQUEST ERROR (' + str(response.status_code) + ')') 36 | 37 | 38 | def user(self, username, limit=5): 39 | ''' 40 | Return username's balance, last transactions and miners in one request. 41 | ''' 42 | 43 | return self._get(f'users/{str(username)}', {'limit':limit}) 44 | 45 | def auth(self, username, password): 46 | ''' 47 | Check username's password. 48 | ''' 49 | 50 | return self._get(f'auth/{str(username)}', {'password':password}) 51 | 52 | def transactions(self, hash=None, limit=None): 53 | ''' 54 | Return all transactions or an unique transaction with that hash. 55 | ''' 56 | 57 | return self._get(f'transactions/{str(hash)}') if hash else self._get('transactions', {'limit':limit} if limit else {}) 58 | 59 | def user_transactions(self, username, limit=10): 60 | ''' 61 | Return transactions related to username. 62 | ''' 63 | 64 | return self._get(f'user_transactions/{str(username)}', {'limit':limit}) 65 | 66 | def id_transactions(self, id): 67 | ''' 68 | Return a transaction with that id. 69 | ''' 70 | 71 | return self._get(f'id_transactions/{str(id)}') 72 | 73 | def transfer(self, username, password, recipient, amount, memo='Powered by pyduinocoin'): 74 | ''' 75 | Transfer funds from username to recipient. 76 | ''' 77 | 78 | return self._get('transaction', {'username':username, 'password':password, 'recipient':recipient, 'amount':amount, 'memo':memo}, results_key=None) 79 | 80 | def miners(self, username=None, limit=None): 81 | ''' 82 | Return all miners or username's miners. 83 | ''' 84 | 85 | return self._get(f'miners/{str(username)}', {'limit':limit} if limit else {}) if username else self._get('miners', {'limit':limit} if limit else {}) 86 | 87 | def balances(self, username=None, limit=None): 88 | ''' 89 | Return all balances or username's balance. 90 | ''' 91 | 92 | return self._get(f'balances/{str(username)}') if username else self._get('balances', {'limit':limit} if limit else {}) 93 | 94 | def statistics(self): 95 | ''' 96 | Return server statistics. 97 | ''' 98 | 99 | return self._get('statistics', results_key=None) 100 | 101 | def all_pools(self): 102 | ''' 103 | Return all non-hidden mining pools. 104 | ''' 105 | 106 | return self._get('all_pools') 107 | 108 | def exchange_request(self, username, password, email, type, amount, coin, address): 109 | ''' 110 | Submit exchange request in the DUCO Exchange. 111 | ''' 112 | 113 | return self._get('exchange_request', {'username':username, 'password':password, 'email':email, 'type':type, 'amount':amount, 'coin':coin, 'address':address}, results_key=None) -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = [ 3 | "requests>=2.21.0", 4 | "setuptools>=42", 5 | "wheel" 6 | ] 7 | build-backend = "setuptools.build_meta" 8 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | with open("README.md", "r", encoding="utf-8") as fh: 4 | long_description = fh.read() 5 | 6 | setuptools.setup( 7 | name="pyduinocoin", 8 | version="1.0.5", 9 | author="Sergio Contreras Agustí (backrndsource)", 10 | author_email="backrndsource@gmail.com", 11 | description="pyDuinoCoin is a simple python integration for the DuinoCoin REST API, that allows developers to communicate with DuinoCoin Master Server.", 12 | long_description=long_description, 13 | long_description_content_type="text/markdown", 14 | url="https://github.com/backrndsource/pyduinocoin", 15 | project_urls={ 16 | "Bug Tracker": "https://github.com/backrndsource/pyduinocoin/issues", 17 | }, 18 | keywords=["DUCO", "DuinoCoin", "api-rest", "python3", "duino", "duino-coin", "api", "client", "REST", "crypto", "coin"], 19 | classifiers=[ 20 | "Development Status :: 5 - Production/Stable", 21 | "Intended Audience :: Developers", 22 | "Topic :: Software Development :: Libraries", 23 | "Programming Language :: Python", 24 | "Programming Language :: Python :: 3", 25 | "Programming Language :: Python :: 3.5", 26 | "Programming Language :: Python :: 3.6", 27 | "Programming Language :: Python :: 3.7", 28 | "Programming Language :: Python :: 3.8", 29 | "Programming Language :: Python :: 3.9", 30 | "License :: OSI Approved :: MIT License", 31 | "Operating System :: OS Independent", 32 | ], 33 | packages=setuptools.find_packages(), 34 | python_requires=">=3.5", 35 | ) 36 | -------------------------------------------------------------------------------- /tests/dict_obj_test.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from unittest import TestCase 3 | from pyduinocoin import DictObj 4 | 5 | 6 | class DictObjTests(TestCase): 7 | def setUp(self): 8 | self.entries = { 9 | 'ti tl%%.-.¨¨ %e': 'images', 10 | 'results': [ 11 | { 12 | 'path': 'img/', 13 | 'title': 'img1' 14 | }, 15 | { 16 | 'path': 'img/', 17 | 'title': 'img2' 18 | } 19 | ], 20 | 'formats': ['.jpg', '.png'], 21 | 'langs': { 22 | 'ES' : 'es-ES', 23 | 'FR': 'fr-FR' 24 | } 25 | } 26 | 27 | def assert_attr(self, dict_obj): 28 | self.assertIsNotNone(dict_obj) 29 | 30 | self.assertTrue(hasattr(dict_obj, 'title')) 31 | self.assertTrue(isinstance(dict_obj.title, str)) 32 | self.assertEqual(dict_obj.title, 'images') 33 | 34 | self.assertTrue(hasattr(dict_obj, 'results')) 35 | self.assertTrue(isinstance(dict_obj.results, list)) 36 | for result in dict_obj.results: 37 | self.assertTrue(isinstance(result, DictObj)) 38 | self.assertTrue(hasattr(result, 'path')) 39 | self.assertTrue(hasattr(result, 'title')) 40 | self.assertTrue(isinstance(result.path, str)) 41 | self.assertTrue(isinstance(result.title, str)) 42 | 43 | self.assertTrue(hasattr(dict_obj, 'formats')) 44 | self.assertTrue(isinstance(dict_obj.formats, list)) 45 | self.assertIn('.jpg', dict_obj.formats) 46 | self.assertIn('.png', dict_obj.formats) 47 | 48 | self.assertTrue(hasattr(dict_obj, 'langs')) 49 | self.assertTrue(isinstance(dict_obj.langs, DictObj)) 50 | self.assertTrue(hasattr(dict_obj.langs, 'ES')) 51 | self.assertTrue(hasattr(dict_obj.langs, 'FR')) 52 | self.assertTrue(isinstance(dict_obj.langs.ES, str)) 53 | self.assertTrue(isinstance(dict_obj.langs.FR, str)) 54 | self.assertEqual(dict_obj.langs.ES, 'es-ES') 55 | self.assertEqual(dict_obj.langs.FR, 'fr-FR') 56 | 57 | def assert_dict(self, dict_obj): 58 | self.assertIsNotNone(dict_obj) 59 | 60 | self.assertIn('title', dict_obj) 61 | self.assertTrue(isinstance(dict_obj['title'], str)) 62 | self.assertEqual(dict_obj['title'], 'images') 63 | 64 | self.assertIn('results', dict_obj) 65 | self.assertTrue(isinstance(dict_obj['results'], list)) 66 | for result in dict_obj['results']: 67 | self.assertTrue(isinstance(result, DictObj)) 68 | self.assertIn('path', result) 69 | self.assertIn('title', result) 70 | self.assertTrue(isinstance(result['path'], str)) 71 | self.assertTrue(isinstance(result['title'], str)) 72 | 73 | self.assertIn('formats', dict_obj) 74 | self.assertTrue(isinstance(dict_obj['formats'], list)) 75 | self.assertIn('.jpg', dict_obj['formats']) 76 | self.assertIn('.png', dict_obj['formats']) 77 | 78 | self.assertIn('langs', dict_obj) 79 | self.assertTrue(isinstance(dict_obj['langs'], DictObj)) 80 | self.assertIn('ES', dict_obj['langs']) 81 | self.assertIn('FR', dict_obj['langs']) 82 | self.assertTrue(isinstance(dict_obj['langs']['ES'], str)) 83 | self.assertTrue(isinstance(dict_obj['langs']['FR'], str)) 84 | self.assertEqual(dict_obj['langs']['ES'], 'es-ES') 85 | self.assertEqual(dict_obj['langs']['FR'], 'fr-FR') 86 | 87 | def test_dict_obj__init__(self): 88 | dict_obj = DictObj(self.entries) 89 | self.assert_attr(dict_obj) 90 | self.assert_dict(dict_obj) 91 | self.assert_dict(dict_obj.__dict__) 92 | 93 | def test_dict_obj__len__(self): 94 | self.assertEqual(len(DictObj(self.entries)), 4) 95 | self.assertEqual(len(DictObj()), 0) 96 | 97 | def test_dict_obj__getitem__(self): 98 | dict_obj = DictObj(self.entries) 99 | self.assertEqual(dict_obj['title'], 'images') 100 | self.assertEqual(dict_obj['results'][0]['path'], 'img/') 101 | self.assertEqual(dict_obj['formats'][0], '.jpg') 102 | self.assertEqual(dict_obj['langs']['ES'], 'es-ES') 103 | 104 | def test_dict_obj__setitem__(self): 105 | dict_obj = DictObj() 106 | dict_obj['title'] = 'images' 107 | dict_obj['results'] = [{'path': 'img/'}] 108 | dict_obj['formats'] = ['.jpg'] 109 | dict_obj['langs'] = {'ES': 'es-ES'} 110 | self.assertEqual(dict_obj['title'], 'images') 111 | self.assertEqual(dict_obj['results'][0]['path'], 'img/') 112 | self.assertEqual(dict_obj['formats'][0], '.jpg') 113 | self.assertEqual(dict_obj['langs']['ES'], 'es-ES') 114 | 115 | def test_dict_obj__delitem__(self): 116 | dict_obj = DictObj(self.entries) 117 | self.assertIn('title', dict_obj) 118 | del dict_obj['title'] 119 | self.assertNotIn('title', dict_obj) 120 | 121 | def test_dict_obj__iter__(self): 122 | try: 123 | iter(DictObj(self.entries)) 124 | except TypeError as e: 125 | self.fail('Not iterable') 126 | 127 | def test_dict_obj__reversed__(self): 128 | if sys.version_info >= (3, 8): 129 | try: 130 | reversed(DictObj(self.entries)) 131 | except TypeError as e: 132 | self.fail('Not reverse iterable') 133 | 134 | def test_dict_obj_clear(self): 135 | dict_obj = DictObj(self.entries) 136 | dict_obj.clear() 137 | self.assertEqual(len(dict_obj), 0) 138 | 139 | def test_dict_obj_copy(self): 140 | dict_obj = DictObj(self.entries) 141 | dict_obj_copy = dict_obj.copy() 142 | self.assertTrue(hasattr(dict_obj_copy, 'title')) 143 | self.assertEqual(dict_obj.__dict__, dict_obj_copy.__dict__) 144 | 145 | def test_dict_obj_fromkeys(self): 146 | dict_obj = DictObj().fromkeys({'a','b'}) 147 | self.assertEqual(len(dict_obj), 2) 148 | self.assertTrue(hasattr(dict_obj, 'a')) 149 | self.assertTrue(hasattr(dict_obj, 'b')) 150 | for value in dict_obj.values(): 151 | self.assertIsNone(value) 152 | 153 | dict_obj = DictObj().fromkeys({'a','b'}, 1) 154 | self.assertEqual(len(dict_obj), 2) 155 | self.assertTrue(hasattr(dict_obj, 'a')) 156 | self.assertTrue(hasattr(dict_obj, 'b')) 157 | for value in dict_obj.values(): 158 | self.assertEqual(value, 1) 159 | 160 | def test_dict_obj_get(self): 161 | get = DictObj(self.entries).get('title') 162 | self.assertEqual(get, 'images') 163 | 164 | def test_dict_obj_items(self): 165 | items = DictObj(self.entries).items() 166 | self.assertEqual(len(items), 4) 167 | self.assertIn(('title', 'images'), items) 168 | 169 | def test_dict_obj_keys(self): 170 | keys = DictObj(self.entries).keys() 171 | self.assertEqual(len(keys), 4) 172 | self.assertIn('title', keys) 173 | 174 | def test_dict_obj_pop(self): 175 | dict_obj = DictObj(self.entries) 176 | pop = dict_obj.pop('title') 177 | self.assertNotIn('title', dict_obj) 178 | self.assertEqual(pop, 'images') 179 | pop = dict_obj.pop('random', 'noexist') 180 | self.assertEqual(pop, 'noexist') 181 | 182 | def test_dict_obj_popitem(self): 183 | popitem = DictObj(self.entries).popitem() 184 | self.assertIsNotNone(popitem) 185 | 186 | def test_dict_obj_setdefault(self): 187 | dict_obj = DictObj(self.entries) 188 | self.assertEqual(dict_obj.setdefault('title'), 'images') 189 | self.assertEqual(dict_obj.setdefault('random', 'modnar'), 'modnar') 190 | 191 | def test_dict_obj_update(self): 192 | dict_obj = DictObj() 193 | dict_obj.update(self.entries) 194 | self.assertTrue(hasattr(dict_obj, 'title')) 195 | 196 | def test_dict_obj_values(self): 197 | values = DictObj(self.entries).values() 198 | self.assertEqual(len(values), 4) 199 | self.assertIn('images', values) 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /tests/exceptions_test.py: -------------------------------------------------------------------------------- 1 | from unittest import TestCase 2 | from pyduinocoin import DuinoClient, PyDuinoCoinException 3 | 4 | 5 | class PyDuinoCoinExceptionTests(TestCase): 6 | def setUp(self): 7 | self.client = DuinoClient() 8 | 9 | def test_exception_user_not_found(self): 10 | try: 11 | self.client.user('sdgsdgerhdfhbxsge4tery56rsgsgr') 12 | except PyDuinoCoinException as exception: 13 | self.assertTrue(isinstance(exception, PyDuinoCoinException)) 14 | self.assertIn('sdgsdgerhdfhbxsge4tery56rsgsgr not found', exception.args[0]) 15 | 16 | -------------------------------------------------------------------------------- /tests/pyduinocoin_test.py: -------------------------------------------------------------------------------- 1 | from unittest import TestCase 2 | from pyduinocoin import DuinoClient, DictObj 3 | 4 | 5 | class DuinoClientTests(TestCase): 6 | def setUp(self): 7 | self.client = DuinoClient() 8 | 9 | def test_get_user(self): 10 | try: 11 | result = self.client.user('Backrndsource') 12 | except Exception as exception: 13 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 14 | print(exception) 15 | else: 16 | self.assertTrue(isinstance(result, DictObj)) 17 | 18 | self.assertTrue(hasattr(result, 'balance')) 19 | self.assertTrue(isinstance(result.balance, DictObj)) 20 | self.assertTrue(hasattr(result.balance, 'balance')) 21 | self.assertTrue(hasattr(result.balance, 'username')) 22 | self.assertEqual(result.balance.username, 'Backrndsource') 23 | 24 | self.assertTrue(hasattr(result, 'miners')) 25 | self.assertTrue(isinstance(result.miners, list)) 26 | 27 | self.assertTrue(hasattr(result, 'transactions')) 28 | self.assertTrue(isinstance(result.transactions, list)) 29 | 30 | print(result) 31 | 32 | def test_get_user_transactions(self): 33 | try: 34 | user_transactions = self.client.user_transactions('Backrndsource', limit=10) 35 | except Exception as exception: 36 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 37 | print(exception) 38 | else: 39 | self.assertTrue(isinstance(user_transactions, list)) 40 | 41 | for transaction in user_transactions: 42 | self.assertTrue(isinstance(transaction, DictObj)) 43 | 44 | print(user_transactions) 45 | 46 | def test_get_miners(self): 47 | try: 48 | miners = self.client.miners(limit=10) 49 | except Exception as exception: 50 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 51 | print(exception) 52 | else: 53 | self.assertTrue(isinstance(miners, DictObj)) 54 | print(miners) 55 | 56 | def test_get_user_miners(self): 57 | try: 58 | miners = self.client.miners('Backrndsource') 59 | except Exception as exception: 60 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 61 | print(exception) 62 | else: 63 | self.assertTrue(isinstance(miners, list)) 64 | print(miners) 65 | 66 | def test_get_balances(self): 67 | try: 68 | balances = self.client.balances() 69 | except Exception as exception: 70 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 71 | print(exception) 72 | else: 73 | self.assertTrue(isinstance(balances, DictObj)) 74 | print(balances) 75 | 76 | def test_get_user_balances(self): 77 | try: 78 | balances = self.client.balances('Backrndsource') 79 | except Exception as exception: 80 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 81 | print(exception) 82 | else: 83 | self.assertTrue(isinstance(balances, DictObj)) 84 | print(balances) 85 | 86 | def test_get_statistics(self): 87 | try: 88 | statistics = self.client.statistics() 89 | except Exception as exception: 90 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 91 | print(exception) 92 | else: 93 | self.assertTrue(isinstance(statistics, DictObj)) 94 | print(statistics) 95 | 96 | def test_get_all_pools(self): 97 | try: 98 | all_pools = self.client.all_pools() 99 | except Exception as exception: 100 | self.assertIn('SERVER REQUEST ERROR', exception.args[0]) 101 | print(exception) 102 | else: 103 | self.assertTrue(isinstance(all_pools, list)) 104 | print(all_pools) 105 | --------------------------------------------------------------------------------