Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop python 3.7 support ~ Add python 3.11 support #77

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ updates:
interval: daily
time: "03:00"

- package-ecosystem: pip
directory: "/.github/workflows"
schedule:
interval: daily
time: "03:30"

- package-ecosystem: "pip"
directory: "/"
schedule:
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v4
id: setup-python
with:
python-version: 3.9
python-version: 3.11

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

Expand Down Expand Up @@ -53,12 +52,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']
include:
- poetry-version: latest
- poetry-version: '1.5.1'
python-version: '3.7'


steps:
- name: Checkout repository
Expand Down Expand Up @@ -96,19 +92,28 @@ jobs:
name: Build package
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
include:
- poetry-version: latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.9
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
id: setup-python
with:
python-version: 3.9
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ matrix.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.9
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pip==23.2.1
poetry==1.6.1
4 changes: 2 additions & 2 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
id: setup-python
with:
python-version: '3.10'
python-version: 3.11

- name: Check licenses
id: licenses
Expand Down
617 changes: 328 additions & 289 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ classifiers = [
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]
description = "Library to interact with the Exonet API."
license = "MIT"
Expand All @@ -21,7 +21,7 @@ version = "4.0.0"

[tool.poetry.dependencies]
inflection = "^0.5.1"
python = "^3.7"
python = "^3.8"
requests = "^2.27.1"

[tool.poetry.dev-dependencies]
Expand Down
13 changes: 7 additions & 6 deletions tests/structures/test_api_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from exonetapi.structures.ApiResource import ApiResource
from exonetapi import create_resource
from exonetapi.RequestBuilder import RequestBuilder

import json

Expand Down Expand Up @@ -154,22 +155,22 @@ def test_to_json_changed_attributes(self):
json.dumps(resource.to_json_changed_attributes()),
)

@mock.patch("exonetapi.RequestBuilder.__init__", return_value=None)
@mock.patch("exonetapi.RequestBuilder.patch")
@mock.patch.object(RequestBuilder, "__init__", return_value=None)
@mock.patch.object(RequestBuilder, "patch")
def test_patch(self, mock_requestbuilder_patch, mock_requestbuilder_init):
mock_requestbuilder_patch.patch = MagicMock(return_value=None)
ApiResource({"type": "fake", "id": "FakeID"}).patch()
mock_requestbuilder_init.assert_called_with("fake")

@mock.patch("exonetapi.RequestBuilder.__init__", return_value=None)
@mock.patch("exonetapi.RequestBuilder.delete")
@mock.patch.object(RequestBuilder, "__init__", return_value=None)
@mock.patch.object(RequestBuilder, "delete")
def test_delete(self, mock_requestbuilder_delete, mock_requestbuilder_init):
mock_requestbuilder_delete.delete = MagicMock(return_value=None)
ApiResource({"type": "fake", "id": "FakeID"}).delete()
mock_requestbuilder_init.assert_called_with("fake")

@mock.patch("exonetapi.RequestBuilder.__init__", return_value=None)
@mock.patch("exonetapi.RequestBuilder.post")
@mock.patch.object(RequestBuilder, "__init__", return_value=None)
@mock.patch.object(RequestBuilder, "post")
def test_post(self, mock_requestbuilder_post, mock_requestbuilder_init):
mock_requestbuilder_post.post = MagicMock(return_value=None)
ApiResource({"type": "fake", "id": "FakeID"}).post()
Expand Down
5 changes: 3 additions & 2 deletions tests/structures/test_api_resource_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from exonetapi.structures.Relationship import Relationship
from exonetapi.structures.Relation import Relation
from exonetapi import create_resource
from exonetapi.RequestBuilder import RequestBuilder

import json

Expand Down Expand Up @@ -156,8 +157,8 @@ def test_related(self):
relation = resource.related("something")
self.assertIsInstance(relation, Relation)

@mock.patch("exonetapi.RequestBuilder.__init__", return_value=None)
@mock.patch("exonetapi.RequestBuilder.get")
@mock.patch.object(RequestBuilder, "__init__", return_value=None)
@mock.patch.object(RequestBuilder, "get")
def test_post(self, mock_requestbuilder_get, mock_requestbuilder_init):
mock_requestbuilder_get.get = MagicMock(return_value=None)
ApiResource({"type": "fake", "id": "FakeID"}).get()
Expand Down
4 changes: 3 additions & 1 deletion tests/structures/test_api_resource_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from exonetapi.structures.ApiResourceSet import ApiResourceSet
from exonetapi.structures.ApiResource import ApiResource
from exonetapi.RequestBuilder import RequestBuilder

from tests.testCase import testCase


Expand All @@ -22,7 +24,7 @@ def test_links(self):

self.assertEqual(links, api_resource_set.links())

@mock.patch("exonetapi.RequestBuilder.get", return_value="api_response")
@mock.patch.object(RequestBuilder, "get", return_value="api_response")
def test_pagination(self, mock_request_builder):
links = {
"next": "https://api.exonet.nl/next_url?filter[unit]=test",
Expand Down
3 changes: 2 additions & 1 deletion tests/structures/test_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tests.testCase import testCase

from exonetapi.structures.Relation import Relation
from exonetapi.RequestBuilder import RequestBuilder


class testRelation(testCase):
Expand All @@ -18,7 +19,7 @@ def test_len_filled(self):

self.assertEqual(3, len(relation))

@mock.patch("exonetapi.RequestBuilder.get", return_value="get_response")
@mock.patch.object(RequestBuilder, "get", return_value="get_response")
def test_getattr(self, mock_request_builder):
"""Call a method on the relation and expect it to be passed to the
RequestBuilder."""
Expand Down
14 changes: 6 additions & 8 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import unittest
from unittest import mock
from unittest.mock import patch

from tests.testCase import testCase
from exonetapi.Client import Client
from exonetapi.RequestBuilder import RequestBuilder
from exonetapi.auth.Authenticator import Authenticator


class testClient(testCase):
@mock.patch("exonetapi.auth.Authenticator.__init__", return_value=None)
@patch.object(Authenticator, "__init__", return_value=None)
def test_init_arguments(self, mock_authenticator):
client = Client("https://test.url")

# Assert the host connection is set up.
mock_authenticator.assert_called_once_with("https://test.url", "/oauth/token")

self.assertEqual(client.get_host(), "https://test.url")
mock_authenticator.assert_called_with("https://test.url", "/oauth/token")

def test_set_host(self):
client = Client("https://test.url")
Expand All @@ -28,7 +30,3 @@ def test_resource(self):
resource = client.resource("/test")

self.assertIsInstance(resource, RequestBuilder)


if __name__ == "__main__":
unittest.main()
22 changes: 14 additions & 8 deletions tests/test_request_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from exonetapi.RequestBuilder import RequestBuilder
from exonetapi.structures.ApiResource import ApiResource
from exonetapi.exceptions.ValidationException import ValidationException
from exonetapi.auth.Authenticator import Authenticator
from exonetapi.result.Parser import Parser


class testRequestBuilder(testCase):
Expand Down Expand Up @@ -81,7 +83,7 @@ def test_sortDesc(self):
self.request_builder._RequestBuilder__query_params["sort"], "-domain"
)

@mock.patch("exonetapi.auth.Authenticator.get_token")
@mock.patch.object(Authenticator, "get_token")
def test_get_headers(self, mock_authenticator_get_token):
mock_authenticator_get_token.return_value = "test_token"

Expand All @@ -95,8 +97,8 @@ def test_get_headers(self, mock_authenticator_get_token):
},
)

@mock.patch("exonetapi.result.Parser.parse")
@mock.patch("exonetapi.result.Parser.__init__")
@mock.patch.object(Parser, "parse")
@mock.patch.object(Parser, "__init__")
@mock.patch("requests.request")
def test_get(self, mock_requests_request, mock_parser_init, mock_parser_parse):
mock_parser_parse.return_value = "parsedReturnValue"
Expand Down Expand Up @@ -124,8 +126,8 @@ def test_get(self, mock_requests_request, mock_parser_init, mock_parser_parse):
self.assertTrue(mock_parser_parse.called)
self.assertEqual("parsedReturnValue", result)

@mock.patch("exonetapi.result.Parser.parse")
@mock.patch("exonetapi.result.Parser.__init__")
@mock.patch.object(Parser, "parse")
@mock.patch.object(Parser, "__init__")
@mock.patch("requests.request")
def test_post(self, mock_requests_request, mock_parser_init, mock_parser_parse):
resource = ApiResource({"type": "things", "id": "someId"})
Expand Down Expand Up @@ -159,8 +161,8 @@ def test_post(self, mock_requests_request, mock_parser_init, mock_parser_parse):
self.assertTrue(mock_parser_parse.called)
self.assertEqual("parsedReturnValue", result)

@mock.patch("exonetapi.result.Parser.parse")
@mock.patch("exonetapi.result.Parser.__init__")
@mock.patch.object(Parser, "parse")
@mock.patch.object(Parser, "__init__")
@mock.patch("requests.request")
def test_post_relation(
self, mock_requests_request, mock_parser_init, mock_parser_parse
Expand Down Expand Up @@ -306,7 +308,11 @@ def test_delete_relation(self, mock_requests_request):
self.assertTrue(result)

@mock.patch("requests.request")
@mock.patch("exonetapi.exceptions.ValidationException.__init__", return_value=None)
@mock.patch.object(
ValidationException,
"__init__",
return_value=None,
)
def test_post_validation_error(
self, mock_validation_exception, mock_requests_request
):
Expand Down