コード例 #1
0
def test_get_new_sales(monkeypatch):
    """regular get_new_sales test"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_getnewsales.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))

    obj = sales_management.get_new_sales()
    assert "getnewsalesresult" in obj.content.tag
コード例 #2
0
def test_get_new_sales(monkeypatch):
    """regular get_new_sales test"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_getnewsales.xml'))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.fr.shopping.rakuten.com"))

    obj = sales_management.get_new_sales()
    assert "getnewsalesresult" in obj.content.tag
コード例 #3
0
def test_get_shipping_information(monkeypatch):
    """get_billing_information test"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_getshippinginformation.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = None
    obj = sales_management.get_shipping_information("1337")
    assert obj is not None
    assert obj.content.tag == "getshippinginformationresult"
コード例 #4
0
def test_get_shipping_information(monkeypatch):
    """get_billing_information test"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_getshippinginformation.xml'))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.fr.shopping.rakuten.com"))
    obj = None
    obj = sales_management.get_shipping_information("1337")
    assert obj is not None
    assert obj.content.tag == "getshippinginformationresult"
コード例 #5
0
def test_cancel_item(connection):
    """cancel_item on an unknown product, must fail"""
    sales_management = SalesManagement(connection)
    obj = None
    try:
        obj = sales_management.cancel_item("1337", "comment")
    except ShibaServiceError:
        pass
    assert obj is None
コード例 #6
0
def test_contact_user_about_item(connection):
    """contact_user_about_item on an unknown product, must fail"""
    sales_management = SalesManagement(connection)
    obj = None
    try:
        obj = sales_management.contact_user_about_item("1337", "message")
    except ShibaServiceError:
        pass
    assert obj is None
コード例 #7
0
def test_get_item_infos(connection):
    """get_item_infos on a unknown product, must fail"""
    sales_management = SalesManagement(connection)
    obj = None
    try:
        obj = sales_management.get_item_infos("181063")
    except ShibaServiceError:
        pass
    assert obj is None
コード例 #8
0
def test_get_shipping_information(connection):
    """get_billing_information test, will raise an error due to unknown purchaseid"""
    sales_management = SalesManagement(connection)
    obj = None
    try:
        obj = sales_management.get_shipping_information("1337")
    except ShibaServiceError:
        pass
    assert obj is None
コード例 #9
0
def test_refuse_sale(connection):
    """Only fail result, as refusing an actual sale is not simulable"""
    sales_management = SalesManagement(connection)
    itemid = "000000"
    obj = None
    try:
        obj = sales_management.refuse_sale(itemid)
    except ShibaServiceError:
        pass
    except ShibaParameterError:
        pass
コード例 #10
0
def test_set_tracking_package_infos(monkeypatch):
    """set_tracking_package_infos on a product. Testing internal error catching as well."""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_settrackingpackageinfos.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.set_tracking_package_infos("1337", "UPS", "0000000000")
    assert obj.content.tag == "setshippingpackageinfosresult"
    obj = None
    try:
        obj = sales_management.set_tracking_package_infos("1337", "Autre", "0000000000")
    except ShibaCallingError:
        pass
    assert obj is None
コード例 #11
0
def test_confirm_preorder(monkeypatch):
    """confirm_preorder on an advert. Testing internal error catching as well."""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_confirmpreorder.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.confirm_preorder("1337", 1)
    assert obj.content.tag == "confirmpreorder"
    obj = None
    try:
        obj = sales_management.confirm_preorder("1337", -8)
    except ShibaCallingError:
        pass
    assert obj is None
コード例 #12
0
def test_accept_sale(monkeypatch):
    """Only fail result, as accepting an actual sale is not simulable"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_accept_sale.xml'))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.fr.shopping.rakuten.com"))
    itemid = "000000"
    obj = None
    try:
        obj = sales_management.accept_sale(itemid)
    except ShibaServiceError:
        pass
    except ShibaParameterError:
        pass
    assert obj is not None
コード例 #13
0
def test_refuse_sale(monkeypatch):
    """Only fail result, as refusing an actual sale is not simulable"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_accept_sale.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    itemid = "000000"
    obj = None
    try:
        obj = sales_management.refuse_sale(itemid)
    except ShibaServiceError:
        pass
    except ShibaParameterError:
        pass
    assert obj is not None
コード例 #14
0
def test_get_current_sales(monkeypatch):
    """get_current_sales test, on variable parameters, plus some fail results"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_getcurrentsales.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.get_current_sales()
    assert "getcurrentsalesresult" in obj.content.tag
    assert not obj.content.request.ispendingpreorder
    try:
        sales_management.get_current_sales(ispendingpreorder="n")
    except ShibaCallingError:
        pass
    obj = sales_management.get_current_sales(purchasedate="WRONGDATE")
    for elem in obj.content.response:
        assert elem.tag != "purchasedate"
コード例 #15
0
def test_confirm_preorder(connection):
    """confirm_preorder on an unknown advert, must fail. Testing internal error catching as well."""
    sales_management = SalesManagement(connection)
    obj = None
    try:
        obj = sales_management.confirm_preorder("1337", 1)
    except ShibaParameterError:
        pass
    assert obj is None
    try:
        obj = sales_management.confirm_preorder("1337", -8)
    except ShibaCallingError:
        pass
    assert obj is None
コード例 #16
0
def test_set_tracking_package_infos(connection):
    """set_tracking_package_infos on an unknown product, must fail. Testing internal error catching as well."""
    sales_management = SalesManagement(connection)
    obj = None
    try:
        obj = sales_management.set_tracking_package_infos("1337", "UPS", "0000000000")
    except ShibaParameterError:
        pass
    assert obj is None
    try:
        obj = sales_management.set_tracking_package_infos("1337", "Autre", "0000000000")
    except ShibaCallingError:
        pass
    assert obj is None
コード例 #17
0
 def setUp(self):
     settings = ConfigParser.ConfigParser()
     try:
         settings.read(os.path.dirname(os.path.realpath(__file__)) + "/Assets/nosetests.cfg")
     except:
         raise ShibaCallingError("error : can't read login ID from the nosetests.cfg file")
     try:
         login = settings.get(str("NoseConfig"), "login")
         pwd = settings.get(str("NoseConfig"), "pwd")
     except:
         raise ShibaCallingError("error : configuration file doesn't seem to be regular")
     self.init = SalesManagement(ShibaConnection(login, pwd, "https://ws.sandbox.priceminister.com"))
コード例 #18
0
def test_get_current_sales(connection):
    """get_current_sales test, on variable parameters, plus some fail results"""
    sales_management = SalesManagement(connection)
    obj = sales_management.get_current_sales()
    assert "getcurrentsalesresult" in obj.content.tag
    assert not obj.content.request.ispendingpreorder
    obj = sales_management.get_current_sales(ispendingpreorder="y")
    assert "getcurrentsalesresult" in obj.content.tag
    assert obj.content.request.ispendingpreorder
    try:
        sales_management.get_current_sales(ispendingpreorder="n")
    except ShibaCallingError:
        pass
    obj = sales_management.get_current_sales(purchasedate="WRONGDATE")
    for elem in obj.content.response:
        assert elem.tag != "purchasedate"
    obj = sales_management.get_current_sales(purchasedate="2012-12-21")
    assert "21/12/2012" == obj.content.request.purchasedate
コード例 #19
0
def test_cancel_item(monkeypatch):
    """cancel_item test"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_cancelitem.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.cancel_item("1337", "comment")
    assert obj.content.tag == "cancelitemresult"
コード例 #20
0
def test_get_item_infos(monkeypatch):
    """get_item_infos on a product"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_getiteminfos.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.get_item_infos("181063")
    assert obj.content.tag == "getiteminfosresult"
コード例 #21
0
def test_get_items_todo_list(monkeypatch):
    """get_items_todo_list routine test"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_getitemtodolist.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.get_item_todo_list()
    assert "getitemtodolistresult" in obj.content.tag
コード例 #22
0
def test_get_item_infos(monkeypatch):
    """get_item_infos on a product"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_getiteminfos.xml'))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.fr.shopping.rakuten.com"))
    obj = sales_management.get_item_infos("181063")
    assert obj.content.tag == "getiteminfosresult"
コード例 #23
0
def test_get_billing_information(monkeypatch):
    """get_billing_information test, will raise an error due to unknown purchaseid"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_getbillinginformation.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.get_billing_information("1337")
    assert obj.content.tag == "getbillinginformationresult"
コード例 #24
0
def test_wrong_user(fake_connection):
    sales_management = SalesManagement(fake_connection)
    try:
        sales_management.get_new_sales()
    except ShibaLoginError:
        pass
コード例 #25
0
def test_get_new_sales(connection):
    """regular get_new_sales test"""
    sales_management = SalesManagement(connection)
    obj = sales_management.get_new_sales()
    assert "getnewsalesresult" in obj.content.tag
コード例 #26
0
def test_get_items_todo_list(connection):
    """get_items_todo_list routine test"""
    sales_management = SalesManagement(connection)
    obj = sales_management.get_item_todo_list()
    assert "getitemtodolistresult" in obj.content.tag
コード例 #27
0
def test_contact_user_about_item(monkeypatch):
    """contact_user_about_item on a product"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_contactuser.xml"))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.sandbox.priceminister.com"))
    obj = sales_management.contact_user_about_item("1337", "message")
    assert obj.content.tag == "contactuseraboutitemresult"
コード例 #28
0
def test_cancel_item(monkeypatch):
    """cancel_item test"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_cancelitem.xml'))
    sales_management = SalesManagement(ShibaConnection("test", "test", "https://ws.fr.shopping.rakuten.com"))
    obj = sales_management.cancel_item("1337", "comment")
    assert obj.content.tag == "cancelitemresult"
コード例 #29
0
 def test_wrong_user(self):
     wronginstance = SalesManagement(ShibaConnection("test", "test"))
     try:
         obj = wronginstance.get_new_sales()
     except ShibaLoginError:
         pass
コード例 #30
0
class SalesManagementTest(unittest.TestCase):
    """SalesManagement class unit tests, as it's not possible to emulate a real seller profile, most of those tests
    are only verifying the proper handling of errors"""
    def setUp(self):
        settings = ConfigParser.ConfigParser()
        try:
            settings.read(os.path.dirname(os.path.realpath(__file__)) + "/Assets/nosetests.cfg")
        except:
            raise ShibaCallingError("error : can't read login ID from the nosetests.cfg file")
        try:
            login = settings.get(str("NoseConfig"), "login")
            pwd = settings.get(str("NoseConfig"), "pwd")
        except:
            raise ShibaCallingError("error : configuration file doesn't seem to be regular")
        self.init = SalesManagement(ShibaConnection(login, pwd, "https://ws.sandbox.priceminister.com"))

    def test_get_new_sales(self):
        """regular get_new_sales test"""
        obj = self.init.get_new_sales()
        self.assertTrue("getnewsalesresult" in obj.content.tag)

    def test_accept_sale(self):
        """Only fail result, as accepting an actual sale is not simulable"""
        itemid = "000000"
        obj = None
        try:
            obj = self.init.accept_sale(itemid)
        except ShibaServiceError:
            pass
        except ShibaParameterError:
            pass

    def test_refuse_sale(self):
        """Only fail result, as refusing an actual sale is not simulable"""
        itemid = "000000"
        obj = None
        try:
            obj = self.init.refuse_sale(itemid)
        except ShibaServiceError:
            pass
        except ShibaParameterError:
            pass

    def test_get_current_sales(self):
        """get_current_sales test, on variable parameters, plus some fail results"""
        obj = self.init.get_current_sales()
        self.assertIn("getcurrentsalesresult", obj.content.tag)
        self.assertFalse(obj.content.request.ispendingpreorder)
        obj = self.init.get_current_sales(ispendingpreorder="y")
        self.assertIn("getcurrentsalesresult", obj.content.tag)
        self.assertTrue(obj.content.request.ispendingpreorder)
        try:
            self.init.get_current_sales(ispendingpreorder="n")
        except ShibaCallingError:
            pass
        obj = self.init.get_current_sales(purchasedate="WRONGDATE")
        self.assertTrue(elem.content.tag is not "purchasedate" for elem in obj.content.response)
        obj = self.init.get_current_sales(purchasedate="2012-12-21")
        self.assertEqual("21/12/2012", obj.content.request.purchasedate)

    def test_get_billing_information(self):
        """get_billing_information test, will raise an error due to unknown purchaseid"""
        obj = None
        try:
            obj = self.init.get_billing_information("1337")
        except ShibaServiceError:
            pass
        self.assertIsNone(obj)

    def test_get_shipping_information(self):
        """get_billing_information test, will raise an error due to unknown purchaseid"""
        obj = None
        try:
            obj = self.init.get_shipping_information("1337")
        except ShibaServiceError:
            pass
        self.assertIsNone(obj)

    def test_get_items_todo_list(self):
        """get_items_todo_list routine test"""
        obj = self.init.get_item_todo_list()
        self.assertIn("getitemtodolistresult", obj.content.tag)

    def test_get_item_infos(self):
        """get_item_infos on a unknown product, must fail"""
        obj = None
        try:
            obj = self.init.get_item_infos("181063")
        except ShibaServiceError:
            pass
        self.assertIsNone(obj)

    def test_cancel_item(self):
        """cancel_item on an unknown product, must fail"""
        obj = None
        try:
            obj = self.init.cancel_item("1337", "comment")
        except ShibaServiceError:
            pass
        self.assertIsNone(obj)

    def test_contact_us_about_item(self):
        """contact_us_about_item on an unknown product, must fail"""
        obj = None
        try:
            obj = self.init.contact_us_about_item("1337", "message", "1337")
        except ShibaServiceError:
            pass
        self.assertIsNone(obj)

    def test_contact_user_about_item(self):
        """contact_user_about_item on an unknown product, must fail"""
        obj = None
        try:
            obj = self.init.contact_user_about_item("1337", "message")
        except ShibaServiceError:
            pass
        self.assertIsNone(obj)

    def test_set_tracking_package_infos(self):
        """set_tracking_package_infos on an unknown product, must fail. Testing internal error catching as well."""
        obj = None
        try:
            obj = self.init.set_tracking_package_infos("1337", "UPS", "0000000000")
        except ShibaParameterError:
            pass
        self.assertIsNone(obj)
        try:
            obj = self.init.set_tracking_package_infos("1337", "Autre", "0000000000")
        except ShibaCallingError:
            pass
        self.assertIsNone(obj)

    def test_confirm_preorder(self):
        """confirm_preorder on an unknown advert, must fail. Testing internal error catching as well."""
        obj = None
        try:
            obj = self.init.confirm_preorder("1337", 1)
        except ShibaParameterError:
            pass
        self.assertIsNone(obj)
        try:
            obj = self.init.confirm_preorder("1337", -8)
        except ShibaCallingError:
            pass
        self.assertIsNone(obj)

    def test_wrong_user(self):
        wronginstance = SalesManagement(ShibaConnection("test", "test"))
        try:
            obj = wronginstance.get_new_sales()
        except ShibaLoginError:
            pass