class TestBinanceGeneric(unittest.TestCase): def setUp(self): print("\n\rstarting unittests") self.unicorn_fy = UnicornFy() self.unicorn_fy_version = str(self.unicorn_fy.get_version()) self.unicorn_fy.get_latest_release_info() self.unicorn_fy.get_latest_version() def test_set_to_false_if_not_exist(self): value = {'key': '', 'blub': 2} self.assertEqual(str(self.unicorn_fy.set_to_false_if_not_exist(value, "invalid")), "{'key': '', 'blub': 2, 'invalid': False}") def test_is_json(self): self.assertFalse(self.unicorn_fy.is_json(False)) def test_result(self): data = '{"result":null,"id":2}' asserted_result = "{'result': None, 'id': 2, 'unicorn_fied': ['binance.com', '" + self.unicorn_fy_version + "']}" self.assertEqual(str(self.unicorn_fy.binance_com_websocket(data)), asserted_result) def test_error(self): data = '{"error":"blahblah"}' asserted_result = "{'error': 'blahblah', 'unicorn_fied': ['binance.com', '" + self.unicorn_fy_version + "']}" self.assertEqual(str(self.unicorn_fy.binance_com_websocket(data)), asserted_result) def test_template(self): data = '' asserted_result = "" self.assertEqual(str(self.unicorn_fy.binance_com_margin_websocket(data)), asserted_result) def tearDown(self): del self.unicorn_fy
# All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. from unicorn_fy.unicorn_fy import UnicornFy unicorn_fy = UnicornFy() print("is_update_availabe: " + str(unicorn_fy.is_update_availabe())) print("get_latest_version: " + str(unicorn_fy.get_latest_version())) # static methods print("get_version: " + str(UnicornFy.get_version())) print("get_latest_release_info: " + str(UnicornFy.get_latest_release_info()))