def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://localhost:{0}/api.test'.format(self.server.port))

        rate = perform_request("EUR", request=req.clone())

        self.assertIsInstance(rate, float)
        self.assertEqual(0.85, rate)
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://localhost:{0}/api.test'.format(
            self.server.port))

        estimate = perform_request("BTC", "ETH", 1.0, request=req.clone())

        self.assertIsInstance(estimate, float)
        self.assertEqual(5.0, estimate)
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://localhost:{0}/api.test'.format(
            self.server.port))

        value = perform_request("BTC", request=req.clone())

        self.assertIsInstance(value, float)
        self.assertEqual(100.0, value)
    def test_perform_request_with_config_without_user_id(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        wallet = perform_request("BTC", config=get_config("tgda2"), request=req.clone())

        self.assertIsInstance(wallet, basestring)
        self.assertEqual("wallet-bitcoin", wallet)
    def test_perform_request_with_config(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        wallet = perform_request("ETH", config="tgda", request=req.clone())

        self.assertIsInstance(wallet, basestring)
        self.assertEqual("wallet-ethereum", wallet)
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        wallet = perform_request("BTC", request=req.clone())

        self.assertIsInstance(wallet, basestring)
        self.assertEqual("bitcoin-wallet", wallet)
Exemple #7
0
    def test_perform_request_with_config_without_user_id(self):
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com",
                                      password="******",
                                      token=None)

        result = perform_request("BTC",
                                 config=get_config("tsmm2"),
                                 request=req.clone())
        self.assertTrue(result)
Exemple #8
0
    def test_perform_request_with_config_without_user_id(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com",
                                      password="******",
                                      token=None)

        mode = perform_request(config=get_config("tgmm2"), request=req.clone())

        self.assertIsInstance(mode, basestring)
        self.assertEqual("ETH", mode)
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        estimates = perform_request(request=req.clone())

        self.assertIsInstance(estimates, dict)
        self.assertIn("MiningSHA-256", estimates.keys())

        self.assertIsInstance(estimates["MiningSHA-256"], float)
        self.assertEqual((1.0/6.0), estimates["MiningSHA-256"])
    def test_perform_request_with_config_without_user_id(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        estimates = perform_request(config=get_config("tgme2"), request=req.clone())

        self.assertIsInstance(estimates, dict)
        self.assertIn("MiningSHA-256", estimates.keys())

        self.assertIsInstance(estimates["MiningSHA-256"], float)
        self.assertEqual((1.0/12.0), estimates["MiningSHA-256"])
Exemple #11
0
    def test_perform_request_with_config(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com",
                                      password="******",
                                      token=None)

        user_id = perform_request(config="tgui3", request=req.clone())

        self.assertIsInstance(user_id, int)
        self.assertEqual(456, user_id)
Exemple #12
0
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com",
                               password="******",
                               token=None)

        result = perform_request("BTC",
                                 0.1,
                                 "bitcoin-wallet",
                                 request=req.clone())
        self.assertTrue(result)
Exemple #13
0
    def test_perform_request_with_config(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com",
                                     password="******",
                                     token=None)

        result = perform_request("BTC",
                                 0.05,
                                 "wallet-bitcoin",
                                 config="tsaw",
                                 request=req.clone())
        self.assertTrue(result)
    def test_perform_request_with_config_without_user_id(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        balances = perform_request(config=get_config("tgb2"), request=req.clone())

        self.assertIsInstance(balances, dict)
        self.assertEqual(3, len(balances))
        self.assertIn("BTC", balances.keys())
        self.assertIn("ETH", balances.keys())
        self.assertIn("Total", balances.keys())

        self.assertEqual(0.1, balances["BTC"])
        self.assertEqual(2.0, balances["ETH"])
        self.assertEqual(50.0, balances["Total"])
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        balances = perform_request(request=req.clone())

        self.assertIsInstance(balances, dict)
        self.assertEqual(3, len(balances))
        self.assertIn("BTC", balances.keys())
        self.assertIn("ETH", balances.keys())
        self.assertIn("Total", balances.keys())

        self.assertEqual(0.2, balances["BTC"])
        self.assertEqual(2.5, balances["ETH"])
        self.assertEqual(70.0, balances["Total"])
    def test_perform_request_with_config(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com",
                                     password="******",
                                     token=None)

        speeds = perform_request(config="tgms", request=req.clone())

        self.assertIsInstance(speeds, dict)
        self.assertIn("MiningSHA-256", speeds.keys())

        self.assertIsInstance(speeds["MiningSHA-256"], float)
        self.assertEqual(5.0, speeds["MiningSHA-256"])
Exemple #17
0
    def test_perform_request_with_error(self):
        server = MockServer()
        server.start()

        req = EobotRequest()
        req.set_base_url('http://localhost:{0}/api.test'.format(server.port))
        req.set_parameter("nosuch", "page")

        with self.assertRaises(RuntimeError):
            req.perform_request()

        server.stop()
Exemple #18
0
    def test_default_values(self):
        req = EobotRequest()

        self.assertEqual(30.0, req._timeout)
        self.assertTrue(req._validate_ssl)
        self.assertEqual(
            'RickDenHaan-Eobot/{0} (+http://github.com/rickdenhaan/eobot-py)'.
            format(__version__), req._user_agent)
        self.assertEqual('https://www.eobot.com/api.aspx', req._base_url)
        self.assertIsInstance(req._parameters, dict)
        self.assertEqual(0, len(req._parameters))
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://localhost:{0}/api.test'.format(
            self.server.port))

        coins = perform_request(request=req.clone())

        self.assertIsInstance(coins, dict)
        self.assertIn("BTC", coins.keys())
        self.assertIn("ETH", coins.keys())

        self.assertIsInstance(coins["BTC"], dict)
        self.assertIsInstance(coins["ETH"], dict)

        self.assertIn("Price", coins["BTC"].keys())
        self.assertIn("Image", coins["BTC"].keys())
        self.assertIn("BigImage", coins["BTC"].keys())

        self.assertIn("Price", coins["ETH"].keys())
        self.assertIn("Image", coins["ETH"].keys())
        self.assertIn("BigImage", coins["ETH"].keys())

        self.assertIsInstance(coins["BTC"]["Price"], float)
        self.assertIsInstance(coins["BTC"]["Image"], basestring)
        self.assertIsInstance(coins["BTC"]["BigImage"], basestring)

        self.assertIsInstance(coins["ETH"]["Price"], float)
        self.assertIsInstance(coins["ETH"]["Image"], basestring)
        self.assertIsInstance(coins["ETH"]["BigImage"], basestring)

        self.assertEqual(100.0, coins["BTC"]["Price"])
        self.assertEqual("http://www.eobot.com/btc.png", coins["BTC"]["Image"])
        self.assertEqual("http://www.eobot.com/btcbig.png",
                         coins["BTC"]["BigImage"])

        self.assertEqual(20.0, coins["ETH"]["Price"])
        self.assertEqual("http://www.eobot.com/eth.png", coins["ETH"]["Image"])
        self.assertEqual("http://www.eobot.com/ethbig.png",
                         coins["ETH"]["BigImage"])
Exemple #20
0
 def test_get_user_agent(self):
     req = EobotRequest()
     self.assertEqual(
         'RickDenHaan-Eobot/{0} (+http://github.com/rickdenhaan/eobot-py)'.
         format(__version__), req.get_user_agent())
     req.set_user_agent("UserAgent")
     self.assertEqual("UserAgent", req.get_user_agent())
    def test_perform_request(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://localhost:{0}/api.test'.format(
            self.server.port))

        fiat = perform_request(request=req.clone())

        self.assertIsInstance(fiat, dict)
        self.assertIn("USD", fiat.keys())
        self.assertIn("EUR", fiat.keys())

        self.assertIsInstance(fiat["USD"], dict)
        self.assertIsInstance(fiat["EUR"], dict)

        self.assertIn("Price", fiat["USD"].keys())
        self.assertIn("Price", fiat["EUR"].keys())

        self.assertIsInstance(fiat["USD"]["Price"], float)
        self.assertIsInstance(fiat["EUR"]["Price"], float)

        self.assertEqual(1.0, fiat["USD"]["Price"])
        self.assertEqual(0.85, fiat["EUR"]["Price"])
    def test_perform_request_with_config(self):
        MockServer.reset()
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com", password="******", token=None)

        self.assertEqual(0.1, get_balances(config="tec", request=req.clone())["BTC"])
        self.assertEqual(2.0, get_balances(config="tec", request=req.clone())["ETH"])

        result = perform_request("BTC", 0.1, "ETH", config="tec", request=req.clone())
        self.assertTrue(result)

        self.assertEqual(0.0, get_balances(config=get_config("tec"), request=req.clone())["BTC"])
        self.assertEqual(2.5, get_balances(config=get_config("tec"), request=req.clone())["ETH"])
Exemple #23
0
    def test_perform_request(self):
        server = MockServer()
        server.start()

        req = EobotRequest()
        req.set_base_url('http://localhost:{0}/api.test'.format(server.port))
        req.set_parameter("coin", "BTC")
        response = req.perform_request()

        server.stop()

        self.assertIsInstance(response, dict)
        self.assertIn("BTC", response)
        self.assertIsInstance(response["BTC"], float)
        self.assertEqual(100.0, response["BTC"])
Exemple #24
0
    def test_perform_request_with_config(self):
        req = EobotRequest()
        req.set_base_url('http://*****:*****@example.com",
                                     password="******",
                                     token=None)

        mode_before = get_mining_mode(config="tsmm", request=req.clone())
        self.assertEqual("ETH", mode_before)

        result = perform_request("BTC", config="tsmm", request=req.clone())
        self.assertTrue(result)

        mode_after = get_mining_mode(config="tsmm", request=req.clone())
        self.assertEqual("BTC", mode_after)
Exemple #25
0
 def test_set_validate_ssl_with_bool(self):
     req = EobotRequest()
     req.set_validate_ssl(False)
     self.assertEqual(False, req._validate_ssl)
Exemple #26
0
 def test_set_user_agent_with_str(self):
     req = EobotRequest()
     req.set_user_agent("UserAgent")
     self.assertEqual("UserAgent", req._user_agent)
Exemple #27
0
    def test_set_user_agent_with_invalid_value(self):
        req = EobotRequest()

        with self.assertRaises(ValueError):
            # noinspection PyTypeChecker
            req.set_user_agent(123)
Exemple #28
0
 def test_get_validate_ssl(self):
     req = EobotRequest()
     self.assertEqual(True, req.get_validate_ssl())
     req.set_validate_ssl(False)
     self.assertEqual(False, req.get_validate_ssl())
Exemple #29
0
    def test_set_user_agent_without_value(self):
        req = EobotRequest()

        with self.assertRaises(TypeError):
            # noinspection PyArgumentList
            req.set_user_agent()
Exemple #30
0
    def test_set_validate_ssl_with_invalid_value(self):
        req = EobotRequest()

        with self.assertRaises(ValueError):
            # noinspection PyTypeChecker
            req.set_validate_ssl(1)