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
|
||||
|
||||
from .test_rest_serializers import TestRestSerializers
|
||||
from .test_websocket_serializers import TestWebSocketSerializers
|
||||
from .test_labeler import TestLabeler
|
||||
from .test_notification import TestNotification
|
||||
from .test_types_labeler import TestTypesLabeler
|
||||
from .test_types_notification import TestTypesNotification
|
||||
from .test_types_serializers import TestTypesSerializers
|
||||
|
||||
def suite():
|
||||
return unittest.TestSuite([
|
||||
unittest.makeSuite(TestRestSerializers),
|
||||
unittest.makeSuite(TestWebSocketSerializers),
|
||||
unittest.makeSuite(TestLabeler),
|
||||
unittest.makeSuite(TestNotification),
|
||||
unittest.makeSuite(TestTypesLabeler),
|
||||
unittest.makeSuite(TestTypesNotification),
|
||||
unittest.makeSuite(TestTypesSerializers),
|
||||
])
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -3,10 +3,10 @@ import unittest
|
||||
from typing import Optional
|
||||
|
||||
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):
|
||||
@dataclass
|
||||
class Test(_Type):
|
||||
@@ -24,8 +24,8 @@ class TestLabeler(unittest.TestCase):
|
||||
self.assertListEqual(serializer.get_labels(), [ "A", "B", "C" ],
|
||||
msg="_Serializer::get_labels() should return the right list of labels.")
|
||||
|
||||
with self.assertRaises(LabelerSerializerException,
|
||||
msg="_Serializer should raise LabelerSerializerException if given " \
|
||||
with self.assertRaises(AssertionError,
|
||||
msg="_Serializer should raise an AssertionError if given " \
|
||||
"fewer arguments than the serializer labels."):
|
||||
serializer.parse(5, 65.0, "X")
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import unittest
|
||||
|
||||
from dataclasses import dataclass
|
||||
from ..labeler import generate_labeler_serializer
|
||||
from ..notification import _Type, _Notification, Notification
|
||||
from .. types.labeler import generate_labeler_serializer
|
||||
from .. types.notification import _Type, _Notification, Notification
|
||||
|
||||
class TestNotification(unittest.TestCase):
|
||||
def test_notification(self):
|
||||
class TestTypesNotification(unittest.TestCase):
|
||||
def test_types_notification(self):
|
||||
@dataclass
|
||||
class Test(_Type):
|
||||
A: int
|
||||
@@ -1,13 +1,9 @@
|
||||
#pylint: disable=duplicate-code
|
||||
|
||||
import unittest
|
||||
from .. types import serializers
|
||||
from .. types.labeler import _Type
|
||||
|
||||
from ..labeler import _Type
|
||||
|
||||
from ..rest import serializers
|
||||
|
||||
class TestRestSerializers(unittest.TestCase):
|
||||
def test_rest_serializers(self):
|
||||
class TestTypesSerializers(unittest.TestCase):
|
||||
def test_types_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 " \
|
||||
@@ -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 .. enums import OrderType, FundingOfferType
|
||||
from ...utils.json_encoder import JSON
|
||||
from ... types import JSON
|
||||
|
||||
class BfxWebSocketInputs:
|
||||
def __init__(self, handle_websocket_input):
|
||||
|
||||
Reference in New Issue
Block a user