Skip to content

Commit feed2a0

Browse files
committed
Update tests to fixes in schemas
1 parent c04cead commit feed2a0

File tree

12 files changed

+186
-144
lines changed

12 files changed

+186
-144
lines changed

tests/test_account_by_key_api/test_account_by_key_api_response_schemas.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import pytest
66

77
from schemas.__private.hive_factory import HiveResult
8-
from schemas.account_by_key_api.responses_from_api import GetKeyReferences
9-
from tests.test_account_by_key_api.response_from_api import GET_KEY_REFERENCES
8+
from schemas.account_by_key_api.response_schemas import GetKeyReferences
9+
10+
from .response_from_api import GET_KEY_REFERENCES
1011

1112

1213
@pytest.mark.parametrize("schema, parameters", [(GetKeyReferences, GET_KEY_REFERENCES)])

tests/test_account_history_api/test_account_history_api_responses_schemas.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
import pytest
77

88
from schemas.__private.hive_factory import HiveError, HiveResult
9-
from schemas.__private.operation_objects import Hf26ApiOperationObject, Hf26ApiVirtualOperationObject
10-
from schemas.__private.operations import Hf26OperationRepresentationType
119
from schemas.account_history_api.response_schemas import (
1210
EnumVirtualOps,
1311
GetAccountHistory,
1412
GetOpsInBlock,
1513
GetTransaction,
1614
)
17-
from tests.test_account_history_api.responses_from_api import (
15+
16+
from .responses_from_api import (
1817
ENUM_VIRTUAL_OPS,
1918
GET_ACCOUNT_HISTORY,
2019
GET_OPS_IN_BLOCK,
@@ -25,10 +24,10 @@
2524
@pytest.mark.parametrize(
2625
"schema, parameters",
2726
[
28-
(EnumVirtualOps[Hf26ApiVirtualOperationObject], ENUM_VIRTUAL_OPS),
29-
(GetAccountHistory[Hf26ApiOperationObject, Hf26ApiVirtualOperationObject], GET_ACCOUNT_HISTORY),
30-
(GetOpsInBlock[Hf26ApiOperationObject, Hf26ApiVirtualOperationObject], GET_OPS_IN_BLOCK),
31-
(GetTransaction[Hf26OperationRepresentationType], GET_TRANSACTION),
27+
(EnumVirtualOps, ENUM_VIRTUAL_OPS),
28+
(GetAccountHistory, GET_ACCOUNT_HISTORY),
29+
(GetOpsInBlock, GET_OPS_IN_BLOCK),
30+
(GetTransaction, GET_TRANSACTION),
3231
],
3332
)
3433
def test_account_history_api_correct_values(parameters: dict[str, Any], schema: Any) -> None:

tests/test_block_api/test_block_api_schemas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
from schemas.__private.hive_factory import HiveResult
88
from schemas.block_api.response_schemas import GetBlock, GetBlockHeader, GetBlockRange
9-
from tests.test_block_api.resonse_schemas import GET_BLOCK, GET_BLOCK_HEADER, GET_BLOCK_RANGE
9+
10+
from .resonse_schemas import GET_BLOCK, GET_BLOCK_HEADER, GET_BLOCK_RANGE
1011

1112

1213
@pytest.mark.parametrize(

tests/test_condenser_api/responses_from_api.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"percent_hbd": 10000,
7272
"post_id": 123721714,
7373
"net_rshares": 19331428900025,
74+
"was_voted_on": True,
7475
"active_votes": [
7576
{"percent": "10000", "reputation": 7606052098882, "rshares": 817822454, "voter": "konelectric"},
7677
{"percent": "10000", "reputation": 7084649348142, "rshares": 399494720371, "voter": "kendewitt"},
@@ -2255,6 +2256,7 @@
22552256
"percent_hbd": 10000,
22562257
"post_id": 123721714,
22572258
"net_rshares": 19331428900025,
2259+
"was_voted_on": True,
22582260
"active_votes": [
22592261
{"percent": "10000", "reputation": 7606052098882, "rshares": 817822454, "voter": "konelectric"},
22602262
{"percent": "10000", "reputation": 7084649348142, "rshares": 399494720371, "voter": "kendewitt"},
@@ -2437,6 +2439,7 @@
24372439
"percent_hbd": 10000,
24382440
"post_id": 123615714,
24392441
"net_rshares": 509581466063,
2442+
"was_voted_on": False,
24402443
"active_votes": [
24412444
{"percent": "10000", "reputation": 280616224641976, "rshares": 474641612071, "voter": "justyy"},
24422445
{"percent": "300", "reputation": 872751821566595, "rshares": 34939853992, "voter": "bozz"},
@@ -2743,6 +2746,7 @@
27432746
"vote_rshares": 19331428900025,
27442747
"net_rshares": 19331428900025,
27452748
"abs_rshares": 19331428900025,
2749+
"was_voted_on": True,
27462750
"active_votes": [
27472751
{
27482752
"percent": 10000,
@@ -3379,6 +3383,7 @@
33793383
"vote_rshares": 0,
33803384
"net_rshares": 0,
33813385
"abs_rshares": 0,
3386+
"was_voted_on": True,
33823387
"active_votes": [],
33833388
},
33843389
{
@@ -3425,6 +3430,7 @@
34253430
"vote_rshares": 0,
34263431
"net_rshares": 0,
34273432
"abs_rshares": 0,
3433+
"was_voted_on": True,
34283434
"active_votes": [],
34293435
},
34303436
{
@@ -3471,6 +3477,7 @@
34713477
"vote_rshares": 28301117063,
34723478
"net_rshares": 28301117063,
34733479
"abs_rshares": 28301117063,
3480+
"was_voted_on": True,
34743481
"active_votes": [
34753482
{
34763483
"percent": 5000,
@@ -3526,6 +3533,7 @@
35263533
"vote_rshares": 0,
35273534
"net_rshares": 0,
35283535
"abs_rshares": 0,
3536+
"was_voted_on": True,
35293537
"active_votes": [],
35303538
},
35313539
],
@@ -3536,7 +3544,7 @@
35363544
"jsonrpc": "2.0",
35373545
"result": {"base": "0.357 HBD", "quote": "1.000 HIVE"},
35383546
}
3539-
GET_ESCROW: Final[dict[str, Any]] = {"jsonrpc": "2.0", "result": "null", "id": 1}
3547+
GET_ESCROW: Final[dict[str, Any]] = {"jsonrpc": "2.0", "result": None, "id": 1}
35403548
GET_FOLLOW_COUNT: Final[dict[str, Any]] = {
35413549
"jsonrpc": "2.0",
35423550
"result": {"account": "hiveio", "following_count": 0, "follower_count": 2023},

tests/test_condenser_api/test_condenser_api_schemas.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@
5959
GetWitnessCount,
6060
GetWitnesses,
6161
GetWitnessesByVote,
62-
GetWitnessesSchedule,
62+
GetWitnessSchedule,
6363
IsKnownTransaction,
6464
ListProposals,
6565
ListProposalVotes,
6666
LookupAccountNames,
6767
LookupAccounts,
6868
)
69-
from tests.test_condenser_api.responses_from_api import (
69+
70+
from .responses_from_api import (
7071
FIND_PROPOSALS,
7172
FIND_RECURRENT_TRANSFERS,
7273
GET_ACCOUNT_COUNT,
@@ -179,7 +180,7 @@
179180
(GetWithdrawRoutes, GET_WITHDRAW_ROUTES),
180181
(GetWitnessByAccount, GET_WITNESS_BY_ACCOUNT),
181182
(GetWitnessCount, GET_WITNESS_COUNT),
182-
(GetWitnessesSchedule, GET_WITNESS_SCHEDULE),
183+
(GetWitnessSchedule, GET_WITNESS_SCHEDULE),
183184
(GetWitnesses, GET_WITNESSES),
184185
(GetWitnessesByVote, GET_WITNESSES_BY_VOTE),
185186
(IsKnownTransaction, IS_KNOWN_TRANSACTION),

tests/test_database_api/reponses_from_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"percent_hbd": 10000,
128128
"net_votes": 128,
129129
"total_vote_weight": 0,
130+
"was_voted_on": True,
130131
"vote_rshares": 0,
131132
"net_rshares": 0,
132133
"abs_rshares": 0,

tests/test_database_api/test_database_api_responses_schemas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
VerifyAuthority,
6060
VerifySignatures,
6161
)
62-
from tests.test_database_api.reponses_from_api import (
62+
63+
from .reponses_from_api import (
6364
FIND_ACCOUNT_RECOVERY_REQUESTS,
6465
FIND_ACCOUNTS,
6566
FIND_CHANGE_RECOVERY_ACCOUNT_REQUESTS,

tests/test_hive_fields.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,14 @@ def test_asset_nai_vests_field_incorrect_amount(value: str) -> None:
167167

168168

169169
@pytest.mark.parametrize(
170-
"value", ["1970-01-01T00:00:00", datetime.datetime.strptime("1970-01-01T00:00:00", "%Y-%m-%dT%H:%M:%S")]
170+
"value, valid", [("1970-01-01T00:00:00", datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc))]
171171
)
172-
def test_hive_datetime_field_correct_values(value: str | datetime.datetime) -> None:
173-
# ARRANGE
174-
expected_date = datetime.datetime.strptime("1970-01-01T00:00:00", "%Y-%m-%dT%H:%M:%S")
175-
expected_date_after_operation = expected_date + datetime.timedelta(days=2)
176-
177-
# ACT
172+
def test_hive_datetime_field_correct_values(value: str, valid: datetime.datetime) -> None:
173+
# ARRANGE & ACT
178174
instance = HiveDateTimeModel(field=value)
179-
operation = instance.field + datetime.timedelta(days=2)
180175

181176
# ASSERT
182-
assert expected_date == instance.field and operation == expected_date_after_operation
177+
assert valid == instance.field
183178

184179

185180
@pytest.mark.parametrize("value", ["1970-01-01"])

tests/test_market_history_api/test_market_history_api_response_schemas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
GetTradeHistory,
1414
GetVolume,
1515
)
16-
from tests.test_market_history_api.response_schemas import (
16+
17+
from .response_schemas import (
1718
GET_MARKET_HISTORY,
1819
GET_MARKET_HISTORY_BUCKETS,
1920
GET_RECENT_TRADES,

0 commit comments

Comments
 (0)