mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
Rewrite bfxapi.tests according to latest changes.
This commit is contained in:
@@ -1,16 +1,14 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from .test_rest_serializers import TestRestSerializers
|
from .test_types_labeler import TestTypesLabeler
|
||||||
from .test_websocket_serializers import TestWebSocketSerializers
|
from .test_types_notification import TestTypesNotification
|
||||||
from .test_labeler import TestLabeler
|
from .test_types_serializers import TestTypesSerializers
|
||||||
from .test_notification import TestNotification
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
return unittest.TestSuite([
|
return unittest.TestSuite([
|
||||||
unittest.makeSuite(TestRestSerializers),
|
unittest.makeSuite(TestTypesLabeler),
|
||||||
unittest.makeSuite(TestWebSocketSerializers),
|
unittest.makeSuite(TestTypesNotification),
|
||||||
unittest.makeSuite(TestLabeler),
|
unittest.makeSuite(TestTypesSerializers),
|
||||||
unittest.makeSuite(TestNotification),
|
|
||||||
])
|
])
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import unittest
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from ..exceptions import LabelerSerializerException
|
|
||||||
from ..labeler import _Type, generate_labeler_serializer, generate_recursive_serializer
|
|
||||||
|
|
||||||
class TestLabeler(unittest.TestCase):
|
from .. types.labeler import _Type, generate_labeler_serializer, generate_recursive_serializer
|
||||||
|
|
||||||
|
class TestTypesLabeler(unittest.TestCase):
|
||||||
def test_generate_labeler_serializer(self):
|
def test_generate_labeler_serializer(self):
|
||||||
@dataclass
|
@dataclass
|
||||||
class Test(_Type):
|
class Test(_Type):
|
||||||
@@ -24,8 +24,8 @@ class TestLabeler(unittest.TestCase):
|
|||||||
self.assertListEqual(serializer.get_labels(), [ "A", "B", "C" ],
|
self.assertListEqual(serializer.get_labels(), [ "A", "B", "C" ],
|
||||||
msg="_Serializer::get_labels() should return the right list of labels.")
|
msg="_Serializer::get_labels() should return the right list of labels.")
|
||||||
|
|
||||||
with self.assertRaises(LabelerSerializerException,
|
with self.assertRaises(AssertionError,
|
||||||
msg="_Serializer should raise LabelerSerializerException if given " \
|
msg="_Serializer should raise an AssertionError if given " \
|
||||||
"fewer arguments than the serializer labels."):
|
"fewer arguments than the serializer labels."):
|
||||||
serializer.parse(5, 65.0, "X")
|
serializer.parse(5, 65.0, "X")
|
||||||
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from ..labeler import generate_labeler_serializer
|
from .. types.labeler import generate_labeler_serializer
|
||||||
from ..notification import _Type, _Notification, Notification
|
from .. types.notification import _Type, _Notification, Notification
|
||||||
|
|
||||||
class TestNotification(unittest.TestCase):
|
class TestTypesNotification(unittest.TestCase):
|
||||||
def test_notification(self):
|
def test_types_notification(self):
|
||||||
@dataclass
|
@dataclass
|
||||||
class Test(_Type):
|
class Test(_Type):
|
||||||
A: int
|
A: int
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
#pylint: disable=duplicate-code
|
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
from .. types import serializers
|
||||||
|
from .. types.labeler import _Type
|
||||||
|
|
||||||
from ..labeler import _Type
|
class TestTypesSerializers(unittest.TestCase):
|
||||||
|
def test_types_serializers(self):
|
||||||
from ..rest import serializers
|
|
||||||
|
|
||||||
class TestRestSerializers(unittest.TestCase):
|
|
||||||
def test_rest_serializers(self):
|
|
||||||
for serializer in map(serializers.__dict__.get, serializers.__serializers__):
|
for serializer in map(serializers.__dict__.get, serializers.__serializers__):
|
||||||
self.assertTrue(issubclass(serializer.klass, _Type),
|
self.assertTrue(issubclass(serializer.klass, _Type),
|
||||||
f"_Serializer <{serializer.name}>: .klass field must be a subclass " \
|
f"_Serializer <{serializer.name}>: .klass field must be a subclass " \
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#pylint: disable=duplicate-code
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from ..labeler import _Type
|
|
||||||
|
|
||||||
from ..websocket import serializers
|
|
||||||
|
|
||||||
class TestWebSocketSerializers(unittest.TestCase):
|
|
||||||
def test_websocket_serializers(self):
|
|
||||||
for serializer in map(serializers.__dict__.get, serializers.__serializers__):
|
|
||||||
self.assertTrue(issubclass(serializer.klass, _Type),
|
|
||||||
f"_Serializer <{serializer.name}>: .klass field must be a subclass " \
|
|
||||||
f"of _Type (got {serializer.klass}).")
|
|
||||||
|
|
||||||
self.assertListEqual(serializer.get_labels(), list(serializer.klass.__annotations__),
|
|
||||||
f"_Serializer <{serializer.name}> and _Type <{serializer.klass.__name__}> " \
|
|
||||||
"must have matching labels and fields.")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
@@ -3,7 +3,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
from typing import Union, Optional, List, Tuple
|
from typing import Union, Optional, List, Tuple
|
||||||
from .. enums import OrderType, FundingOfferType
|
from .. enums import OrderType, FundingOfferType
|
||||||
from ...utils.json_encoder import JSON
|
from ... types import JSON
|
||||||
|
|
||||||
class BfxWebSocketInputs:
|
class BfxWebSocketInputs:
|
||||||
def __init__(self, handle_websocket_input):
|
def __init__(self, handle_websocket_input):
|
||||||
|
|||||||
Reference in New Issue
Block a user