Skip to content

Commit 819f532

Browse files
committed
tests reformatted
1 parent a4a9b59 commit 819f532

File tree

4 files changed

+49
-31
lines changed

4 files changed

+49
-31
lines changed

tests/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# coding: utf-8
2-

tests/test_serde.py

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33

44
from six import with_metaclass
55

6-
from exonum.datatypes import (Decimal, EncodingStruct, SocketAddr, Str, Uuid,
7-
Vec, i64, u8, u16)
6+
from exonum.datatypes import (
7+
Decimal,
8+
EncodingStruct,
9+
SocketAddr,
10+
Str,
11+
Uuid,
12+
Vec,
13+
i64,
14+
u8,
15+
u16,
16+
)
817

918

1019
def test_simple():
@@ -29,10 +38,7 @@ class X(with_metaclass(EncodingStruct)):
2938
third = i64()
3039
fourth = Str()
3140

32-
x1 = X(first=u"Это строка",
33-
second=2,
34-
third=-658979879,
35-
fourth=u"یہ بھی ایک تار ہے")
41+
x1 = X(first=u"Это строка", second=2, third=-658979879, fourth=u"یہ بھی ایک تار ہے")
3642

3743
b = x1.to_bytes()
3844
x2 = X.read_buffer(b)
@@ -47,8 +53,7 @@ class X(with_metaclass(EncodingStruct)):
4753
first = Vec(u16)
4854
second = Str()
4955

50-
x1 = X(first=[1, 2, 3, 4, 5],
51-
second=u"фывапролдж!")
56+
x1 = X(first=[1, 2, 3, 4, 5], second=u"фывапролдж!")
5257
b = x1.to_bytes()
5358
x2 = X.read_buffer(b)
5459

@@ -80,6 +85,7 @@ class X(with_metaclass(EncodingStruct)):
8085
# xx = X.read_buffer(raw)
8186
# assert xx.f.val == x.f.val
8287

88+
8389
def test_inner():
8490
class X(with_metaclass(EncodingStruct)):
8591
first = Vec(u16)
@@ -93,9 +99,13 @@ class Y(with_metaclass(EncodingStruct)):
9399
raw = f.read()
94100
y_exonum = Y.read_buffer(raw)
95101

96-
y = Y(k=-1000000,
97-
j=[X(first=[1, 2, 3, 4, 5], second=u"x one"),
98-
X(first=[6, 7, 8, 9], second=u"x two")])
102+
y = Y(
103+
k=-1000000,
104+
j=[
105+
X(first=[1, 2, 3, 4, 5], second=u"x one"),
106+
X(first=[6, 7, 8, 9], second=u"x two"),
107+
],
108+
)
99109

100110
assert y_exonum.k == y.k
101111
assert y_exonum.j[1].second.val == y.j[1].second.val
@@ -107,13 +117,15 @@ class Y(with_metaclass(EncodingStruct)):
107117
assert y.k == y2.k
108118
assert y.j == y2.j
109119

110-
s = (u"Y (k = i64(-1000000), "
111-
"j = Vec<X> ["
112-
"X (first = Vec<u16> [u16(1), u16(2), u16(3), u16(4), u16(5)], "
113-
"second = Str(x one)), "
114-
"X (first = Vec<u16> [u16(6), u16(7), u16(8), u16(9)],"
115-
" second = Str(x two))"
116-
"])")
120+
s = (
121+
u"Y (k = i64(-1000000), "
122+
"j = Vec<X> ["
123+
"X (first = Vec<u16> [u16(1), u16(2), u16(3), u16(4), u16(5)], "
124+
"second = Str(x one)), "
125+
"X (first = Vec<u16> [u16(6), u16(7), u16(8), u16(9)],"
126+
" second = Str(x two))"
127+
"])"
128+
)
117129

118130
assert str(y) == s
119131
assert str(y2) == s
@@ -124,8 +136,7 @@ class U(with_metaclass(EncodingStruct)):
124136
soc = Vec(SocketAddr)
125137
ids = Vec(Uuid)
126138

127-
u = U(soc=[("10.1.1.1", 8080), ("192.168.1.1", 9000)],
128-
ids=[uuid4(), uuid4()])
139+
u = U(soc=[("10.1.1.1", 8080), ("192.168.1.1", 9000)], ids=[uuid4(), uuid4()])
129140

130141
b = u.to_bytes()
131142
u2 = U.read_buffer(b)
@@ -135,6 +146,7 @@ class U(with_metaclass(EncodingStruct)):
135146
def test_decimals():
136147
class D(with_metaclass(EncodingStruct)):
137148
d = Decimal()
149+
138150
d = D(d="192837.123")
139151
b = d.to_bytes()
140152
d2 = D.read_buffer(b)

tests/test_tx.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# __metaclass__ = exonum.EncodingStruct
2121
# ...
2222

23+
2324
class Policy(with_metaclass(exonum.EncodingStruct)):
2425
policy_type = exonum.Str()
2526
unique_id = exonum.Str()
@@ -48,11 +49,15 @@ class CreatePolicy(with_metaclass(exonum.EncodingStruct)):
4849
public_key = exonum.PublicKey()
4950

5051

51-
skey = codecs.decode("b61cea151245c2be5d3f89977891e5127a0b4c522ca9760"
52-
"076cdd1f195f0525f692e5734b12d3446def47954c9d4d4"
53-
"ffcf6494d621e2a117e77c6ba07b093038", "hex")
52+
skey = codecs.decode(
53+
"b61cea151245c2be5d3f89977891e5127a0b4c522ca9760"
54+
"076cdd1f195f0525f692e5734b12d3446def47954c9d4d4"
55+
"ffcf6494d621e2a117e77c6ba07b093038",
56+
"hex",
57+
)
5458
pkey = codecs.decode(
55-
"692e5734b12d3446def47954c9d4d4ffcf6494d621e2a117e77c6ba07b093038", "hex")
59+
"692e5734b12d3446def47954c9d4d4ffcf6494d621e2a117e77c6ba07b093038", "hex"
60+
)
5661

5762

5863
def test_tx_serialize():
@@ -75,11 +80,10 @@ def test_tx_serialize():
7580
tax_ammount=5,
7681
risk_management_fee=6,
7782
commision=7,
78-
net_premium_due=8)
83+
net_premium_due=8,
84+
)
7985

80-
tx = CreatePolicy(
81-
content=p,
82-
public_key=pkey)
86+
tx = CreatePolicy(content=p, public_key=pkey)
8387

8488
data = tx.tx(skey, hex=True)
8589

work.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
# a.tx(secret_key)
2525

2626
public_key = bytes.fromhex(
27-
"0f17189c062e7f3fbb47a21834d41e4d5c5388dd7db38c4de1ce732971a38ef9")
27+
"0f17189c062e7f3fbb47a21834d41e4d5c5388dd7db38c4de1ce732971a38ef9"
28+
)
2829
secret_key = bytes.fromhex(
29-
"5520c351b7760aedeef32687918eb2587ab515e4ae0eeef271a0f0a99f1df3710f17189c062e7f3fbb47a21834d41e4d5c5388dd7db38c4de1ce732971a38ef9")
30+
"5520c351b7760aedeef32687918eb2587ab515e4ae0eeef271a0f0a99f1df3710f17189c062e7f3fbb47a21834d41e4d5c5388dd7db38c4de1ce732971a38ef9"
31+
)
3032

3133

3234
@transactions
@@ -38,4 +40,5 @@ class CreateUser(metaclass=exonum.EncodingStruct):
3840
a = CreateUser(public_key=public_key, name="Me")
3941

4042
import json
43+
4144
print(json.dumps(a.tx(secret_key), indent=2))

0 commit comments

Comments
 (0)