def test_get_balance_fail(client: SMSC, params: dict): f = furl(URL).add(path="balance.php").add(params).remove('sender') with requests_mock.Mocker() as m: m.get(f.url, json={}, headers={'Content-Type': 'application/json; charset=utf-8'}, status_code=404) with pytest.raises(GetBalanceError): client.get_balance()
def test_get_balance(client: SMSC, params: dict): f = furl(URL).add(path="balance.php").add(params).remove('sender') with requests_mock.Mocker() as m: m.get(f.url, json={ 'balance': '100.01', 'currency': 'RUR' }, headers={'Content-Type': 'application/json; charset=utf-8'}) res = client.get_balance() assert res is not None assert isinstance(res, BalanceResponse) assert str( res) == "<BalanceResponse balance=100.01 credit=0.00 currency=RUR>" assert res.balance == 100.01 assert res.credit == 0.0 assert res.currency == 'RUR'