Skip to content

Commit

Permalink
Cleanup code and update acceptsale version
Browse files Browse the repository at this point in the history
  • Loading branch information
chocobn69 committed Jul 16, 2021
1 parent 28faeea commit 023e7a8
Show file tree
Hide file tree
Showing 25 changed files with 26 additions and 57 deletions.
1 change: 0 additions & 1 deletion scripts/bumpversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# coding: utf-8
from __future__ import unicode_literals, print_function
import sys
import os
import re
Expand Down
2 changes: 1 addition & 1 deletion shiba/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.1.12"
__version__ = "1.2.0"
VERSION = __version__
2 changes: 0 additions & 2 deletions shiba/accountingmanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from datetime import date

from .shibaconnection import ShibaConnection
Expand Down
2 changes: 1 addition & 1 deletion shiba/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def reraise(tp, value, tb=None):
def is_bytes(x):
return isinstance(x, (bytes, memoryview, bytearray))

from collections import Callable
from collections.abc import Callable

def callable(obj):
return isinstance(obj, Callable)
Expand Down
2 changes: 0 additions & 2 deletions shiba/inventorymanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from .shibaconnection import ShibaConnection
from .shibaexceptions import ShibaCallingError
from .shibatools import (
Expand Down
2 changes: 0 additions & 2 deletions shiba/marketplacemanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from .shibaconnection import ShibaConnection
from .shibatools import inf_constructor, url_constructor, retrieve_obj_from_url
from .compat import basestring
Expand Down
5 changes: 2 additions & 3 deletions shiba/salesmanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from datetime import date

from .shibaconnection import ShibaConnection
Expand All @@ -26,10 +24,11 @@ def get_new_sales(self):
obj = retrieve_obj_from_url(url)
return obj

def accept_sale(self, itemid):
def accept_sale(self, itemid, shippingfromcountry):
"""Accept the "itemid" sale.
:param itemid: string for item ID
:param shippingfromcountry: string ISO code for country
"""
inf = inf_constructor(self.connection, "acceptsale", **locals())
url = url_constructor(self.connection, inf)
Expand Down
4 changes: 1 addition & 3 deletions shiba/shibaconnection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


class ShibaConnection(object):
"""The main Shiba class, standing as an initialization and mandatory for each submodules instancing.
Expand Down Expand Up @@ -76,7 +74,7 @@ def __init__(self, login, pwd, sandbox=False):
},
"acceptsale": {
"cat": "sales_ws",
"version": "2010-09-20",
"version": "2021-04-08",
"login": self.login,
"pwd": self.pwd,
},
Expand Down
2 changes: 0 additions & 2 deletions shiba/shibaexceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
""" Those exception classes will usually be raised after an error returned from the WebServices."""
from __future__ import unicode_literals


class ShibaException(Exception):
"""Main exception class, as you can catch the whole of Shiba exceptions from it"""
Expand Down
2 changes: 0 additions & 2 deletions shiba/shibaresponseobject.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


class ShibaResponseObject(object):
"""This class gathers all content from the returned XML. Separating the namespace for further usage and the actual
Expand Down
2 changes: 0 additions & 2 deletions shiba/shibatools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
""" Tools used by Shiba data retrieving classes"""
from __future__ import unicode_literals

import re
from collections import OrderedDict

Expand Down
24 changes: 16 additions & 8 deletions tests/offline/Assets/sample_accept_sale.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<saleacceptanceresult xmlns="http://www.priceminister.com/sales_ws/saleacceptance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.priceminister.com/sales_ws/saleacceptance http://www.priceminister.com/res/co/0/www/www/56991/2010-09-20sale_acceptance.xsd">
<request>
<user>vendeur</user>
<version>2010-09-20</version>
<itemid>1046920728</itemid>
<saleacceptanceresult xmlns="https://fr.shopping.rakuten.com/res/schema/acceptsale" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://fr.shopping.rakuten.com/res/schema/acceptsale https://fr.shopping.rakuten.com/res/schema/acceptsale/accept_sale.2021-04-08.xsd">
<request>
<version>2021-04-08</version>
<user>uuyu</user>
<itemid>589871029</itemid>
<shippingfromcountry>156</shippingfromcountry>
<importcountry>56</importcountry>
</request>
<response>
<lastversion>2010-09-20</lastversion>
<status>Refused</status>
<lastversion>2021-04-08</lastversion>
<status>Accepted</status>
<shippingfromcountry>156</shippingfromcountry>
<importcountry>56</importcountry>
<onestopshop>
<type>myOSSType</type>
<value>myOSSValue</value>
</onestopshop>
</response>
</saleacceptanceresult>
</saleacceptanceresult>
1 change: 0 additions & 1 deletion tests/offline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# coding: utf-8
from __future__ import unicode_literals, print_function
import os
import pytest

Expand Down
2 changes: 0 additions & 2 deletions tests/offline/test_accountingmanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from shiba.accountingmanagement import AccountingManagement
from shiba.shibaconnection import ShibaConnection

Expand Down
2 changes: 0 additions & 2 deletions tests/offline/test_inventorymanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os.path as op
from shiba.inventorymanagement import InventoryManagement
from shiba.shibaconnection import ShibaConnection
Expand Down
2 changes: 0 additions & 2 deletions tests/offline/test_marketplacemanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from shiba.marketplacemanagement import MarketplaceManagement
from shiba.shibaconnection import ShibaConnection

Expand Down
6 changes: 3 additions & 3 deletions tests/offline/test_salesmanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from shiba.salesmanagement import SalesManagement
from shiba.shibaconnection import ShibaConnection
from shiba.shibaexceptions import (
Expand Down Expand Up @@ -34,16 +32,18 @@ def test_accept_sale(monkeypatch):
ShibaConnection("test", "test", "https://ws.fr.shopping.rakuten.com")
)
itemid = "000000"
shippingfromcountry = "CN"
obj = None
try:
obj = sales_management.accept_sale(itemid)
obj = sales_management.accept_sale(itemid, shippingfromcountry)
except ShibaServiceError:
pass
except ShibaParameterError:
pass
assert obj is not None



def test_refuse_sale(monkeypatch):
"""Only fail result, as refusing an actual sale is not simulable"""
monkeypatch.setattr(
Expand Down
2 changes: 0 additions & 2 deletions tests/offline/test_shibatools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import os.path as op
import xmltodict

Expand Down
2 changes: 0 additions & 2 deletions tests/online/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# coding: utf-8
from __future__ import unicode_literals, print_function

import pytest

from contextlib import contextmanager
Expand Down
2 changes: 0 additions & 2 deletions tests/online/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# coding: utf-8
from __future__ import unicode_literals, print_function

import os

import pytest
Expand Down
2 changes: 0 additions & 2 deletions tests/online/test_accountingmanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from shiba.accountingmanagement import AccountingManagement
from shiba.shibaexceptions import ShibaParameterError

Expand Down
2 changes: 0 additions & 2 deletions tests/online/test_inventorymanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from shiba.shibaexceptions import ShibaRightsError
from shiba.inventorymanagement import InventoryManagement

Expand Down
3 changes: 0 additions & 3 deletions tests/online/test_marketplacemanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
from __future__ import unicode_literals

from shiba.marketplacemanagement import MarketplaceManagement
from shiba.shibaexceptions import *

Expand Down
5 changes: 2 additions & 3 deletions tests/online/test_salesmanagement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from shiba.salesmanagement import SalesManagement
from shiba.shibaexceptions import *

Expand All @@ -16,9 +14,10 @@ def test_accept_sale(connection):
"""Only fail result, as accepting an actual sale is not simulable"""
sales_management = SalesManagement(connection)
itemid = "000000"
shippingfromcountry = "CN"
obj = None
try:
obj = sales_management.accept_sale(itemid)
obj = sales_management.accept_sale(itemid, shippingfromcountry)
except ShibaServiceError:
pass
except ShibaParameterError:
Expand Down
2 changes: 0 additions & 2 deletions tests/online/test_shibatools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from shiba.shibatools import (
inf_constructor,
retrieve_obj_from_url,
Expand Down

0 comments on commit 023e7a8

Please sign in to comment.