Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Connect SDK Changes History

## v17.6

* Fix: `ServerErrorResponseSchema` has a wrong errors field definition, it must be a list of strings.
* Fix: `function_log` decorator use list comprehension to set a custom formatter for each logging handler configured for the current logger. Changed to a for loop.

## v17.5

* Fix: UsageFileAction's subclass SubmitUsageFile has a rejection note, a parameter which should go in RejectUsageFile instead.
Expand Down
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Connect Python SDK allows an easy and fast integration with Connect fulfillment

Please check the documentation available [here](https://connect-python-sdk.readthedocs.io), which contains information on how to install and use the library, and a complete API reference guide.

### Main Features
## Main Features

This library may be consumed in your project in order to automate the fulfillment of requests, this class once imported into your project will allow you to:

Expand All @@ -29,14 +29,48 @@ This library may be consumed in your project in order to automate the fulfillmen

Your code may use any scheduler to execute, from a simple cron to a cloud scheduler like the ones available in Azure, Google, Amazon or other cloud platforms.

### Installation
## Installation

```sh
$ pip install connect-sdk
```

### Requirements
## Requirements

* Python 2.7+ or Python 3.4+
* Requests (https://pypi.org/project/requests/)
* Marshmallow (https://pypi.org/project/marshmallow/)

## Contribute

If you want to contribute to the connect-python-sdk development feel free to open issues or fork the github repository and submit your pull request.

## Development

### Getting started

Assuming that you have python and virtualenv installed, and forked the connect-python-sdk repository, set up your environment and install the required dependencies like this:

```sh
$ git clone https://github.com/{your_github_account}/connect-python-sdk.git
$ cd connect-python-sdk
$ virtualenv venv
$ . venv/bin/activate
$ pip install -r requirements/test.txt
```

### Running tests

The connect-python-sdk uses [pytest](https://docs.pytest.org/en/latest/) for unit testing.

To run the entire tests suite execute:

```sh
$ pytest
```

## License

The connect-python-sdk is released under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).


4 changes: 2 additions & 2 deletions connect/logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def function_log(custom_logger=None):
custom_logger = logging.getLogger()
sformat = " %(levelname)-6s; %(asctime)s; %(name)-6s; %(module)s:%(funcName)s:line" \
"-%(lineno)d: %(message)s"
[handler.setFormatter(logging.Formatter(sformat, "%I:%M:%S"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line allocates a list in memory that is never used

for handler in custom_logger.handlers]
for handler in custom_logger.handlers:
handler.setFormatter(logging.Formatter(sformat, "%I:%M:%S"))

# noinspection PyUnusedLocal
def decorator(func, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion connect/models/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def make_object(self, data):
class ServerErrorResponseSchema(BaseSchema):
error_code = fields.Str()
params = fields.Dict()
errors = fields.Str(many=True)
errors = fields.List(fields.Str())

@post_load
def make_object(self, data):
Expand Down
16 changes: 16 additions & 0 deletions tests/data/response_server_error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"errors": [
"error_str_1",
"error_str_2"
],
"error_code": "ERR_000",
"params": {
"param1": "value",
"param2": false,
"param3": ["a", "b", "c"],
"param4": {
"key": "value"
},
"param5": 10
}
}
23 changes: 23 additions & 0 deletions tests/test_server_error_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-

# This file is part of the Ingram Micro Cloud Blue Connect SDK.
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.

import os

from connect.models import ServerErrorResponse
from .common import load_str


server_error_response_content = load_str(
os.path.join(os.path.dirname(__file__), 'data', 'response_server_error.json'))


def test_server_error_response_attributes():
# type: () -> None
srv_error = ServerErrorResponse.deserialize(server_error_response_content)
assert isinstance(srv_error, ServerErrorResponse)
assert srv_error.error_code == 'ERR_000'
assert isinstance(srv_error.errors, list)
assert len(srv_error.errors) == 2
assert isinstance(srv_error.params, dict)