diff --git a/.github/workflows/bitfinex-api-py-ci.yml b/.github/workflows/bitfinex-api-py-ci.yml index 295ce9f..9c2cbb7 100644 --- a/.github/workflows/bitfinex-api-py-ci.yml +++ b/.github/workflows/bitfinex-api-py-ci.yml @@ -27,5 +27,3 @@ jobs: run: python -m pylint bfxapi - name: Run mypy to check the correctness of type hinting (and fail if any error or warning is found) run: python -m mypy bfxapi - - name: Execute project's unit tests (unittest) - run: python -m unittest bfxapi.tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c9210f6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: python -python: - - "3.8.0" -before_install: - - python -m pip install --upgrade pip -install: - - pip install -r dev-requirements.txt -script: - - python -m pylint bfxapi - - python -m mypy bfxapi - - python -m unittest bfxapi.tests diff --git a/README.md b/README.md index 38caf3d..a564c54 100644 --- a/README.md +++ b/README.md @@ -313,7 +313,6 @@ Contributors must uphold the [Contributor Covenant code of conduct](https://gith * [Cloning the repository](#cloning-the-repository) * [Installing the dependencies](#installing-the-dependencies) 2. [Before opening a PR](#before-opening-a-pr) - * [Running the unit tests](#running-the-unit-tests) 3. [License](#license) ## Installation and setup @@ -349,24 +348,9 @@ Wheter you're submitting a bug fix, a new feature or a documentation change, you All PRs must follow this [PULL_REQUEST_TEMPLATE](https://github.com/bitfinexcom/bitfinex-api-py/blob/v3-beta/.github/PULL_REQUEST_TEMPLATE.md) and include an exhaustive description. Before opening a pull request, you should also make sure that: -- [ ] all unit tests pass (see [Running the unit tests](#running-the-unit-tests)). - [ ] [`pylint`](https://github.com/pylint-dev/pylint) returns a score of 10.00/10.00 when run against your code. - [ ] [`mypy`](https://github.com/python/mypy) doesn't throw any error code when run on the project (excluding notes). -### Running the unit tests - -`bitfinex-api-py` comes with a set of unit tests (written using the [`unittest`](https://docs.python.org/3.8/library/unittest.html) unit testing framework). \ -Contributors must ensure that each unit test passes before opening a pull request. \ -You can run all project's unit tests by calling `unittest` on `bfxapi.tests`: -```console -python3 -m unittest -v bfxapi.tests -``` - -A single unit test can be run as follows: -```console -python3 -m unittest -v bfxapi.tests.test_notification -``` - ## License ``` diff --git a/bfxapi/tests/__init__.py b/bfxapi/tests/__init__.py deleted file mode 100644 index e7a6f4e..0000000 --- a/bfxapi/tests/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -import unittest - -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(TestTypesLabeler), - unittest.makeSuite(TestTypesNotification), - unittest.makeSuite(TestTypesSerializers), - ]) - -if __name__ == "__main__": - unittest.TextTestRunner().run(suite()) diff --git a/bfxapi/tests/test_types_labeler.py b/bfxapi/tests/test_types_labeler.py deleted file mode 100644 index 639736b..0000000 --- a/bfxapi/tests/test_types_labeler.py +++ /dev/null @@ -1,56 +0,0 @@ -import unittest - -from typing import Optional - -from dataclasses import dataclass - -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): - A: Optional[int] - B: float - C: str - - labels = [ "A", "_PLACEHOLDER", "B", "_PLACEHOLDER", "C" ] - - serializer = generate_labeler_serializer("Test", Test, labels) - - self.assertEqual(serializer.parse(5, None, 65.0, None, "X"), Test(5, 65.0, "X"), - msg="_Serializer should produce the right result.") - - self.assertListEqual(serializer.get_labels(), [ "A", "B", "C" ], - msg="_Serializer::get_labels() should return the right list of labels.") - - with self.assertRaises(AssertionError, - msg="_Serializer should raise an AssertionError if given " \ - "fewer arguments than the serializer labels."): - serializer.parse(5, 65.0, "X") - - def test_generate_recursive_serializer(self): - @dataclass - class Outer(_Type): - A: int - B: float - C: "Middle" - - @dataclass - class Middle(_Type): - D: str - E: "Inner" - - @dataclass - class Inner(_Type): - F: bool - - inner = generate_labeler_serializer("Inner", Inner, ["F"]) - middle = generate_recursive_serializer("Middle", Middle, ["D", "E"], serializers={ "E": inner }) - outer = generate_recursive_serializer("Outer", Outer, ["A", "B", "C"], serializers={ "C": middle }) - - self.assertEqual(outer.parse(10, 45.5, [ "Y", [ True ] ]), Outer(10, 45.5, Middle("Y", Inner(True))), - msg="_RecursiveSerializer should produce the right result.") - -if __name__ == "__main__": - unittest.main() diff --git a/bfxapi/tests/test_types_notification.py b/bfxapi/tests/test_types_notification.py deleted file mode 100644 index 007f263..0000000 --- a/bfxapi/tests/test_types_notification.py +++ /dev/null @@ -1,29 +0,0 @@ -import unittest - -from dataclasses import dataclass -from ..types.labeler import generate_labeler_serializer -from ..types.notification import _Type, _Notification, Notification - -class TestTypesNotification(unittest.TestCase): - def test_types_notification(self): - @dataclass - class Test(_Type): - A: int - B: float - C: str - - test = generate_labeler_serializer("Test", Test, - [ "A", "_PLACEHOLDER", "B", "_PLACEHOLDER", "C" ]) - - notification = _Notification[Test](test) - - actual = notification.parse(*[ 1675787861506, "test", None, None, [ 5, None, 65.0, None, "X" ], \ - 0, "SUCCESS", "This is just a test notification." ]) - - expected = Notification[Test](1675787861506, "test", None, Test(5, 65.0, "X"), - 0, "SUCCESS", "This is just a test notification.") - - self.assertEqual(actual, expected, msg="_Notification should produce the right notification.") - -if __name__ == "__main__": - unittest.main() diff --git a/bfxapi/tests/test_types_serializers.py b/bfxapi/tests/test_types_serializers.py deleted file mode 100644 index b5b2695..0000000 --- a/bfxapi/tests/test_types_serializers.py +++ /dev/null @@ -1,17 +0,0 @@ -import unittest -from ..types import serializers -from ..types.labeler import _Type - -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 " \ - 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()