Пример #1
0
class MarketplaceManagementTest(unittest.TestCase):

    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 = MarketplaceManagement(ShibaConnection(login, pwd, "https://ws.sandbox.priceminister.com"))

    def test_get_product_list(self):
        """testing get_product_list methods with different queries, with some invalid ones as well"""
        try:
            obj = self.init.get_product_list()
        except ShibaParameterError:
            pass
        obj = self.init.get_product_list(kw="livre")
        self.assertIn("listingresult", obj.content.tag)
        try:
            obj = self.init.get_product_list(nbproductsperpage=-15, kw="livre")
        except ShibaParameterError:
            pass
        obj = self.init.get_product_list(kw="informatique", scope="PRICING")
        self.assertIn("listingresult", obj.content.tag)

    def test_get_category_map(self):
        """get_category_map regular test"""
        obj = self.init.get_category_map()
        self.assertIn("categorymap", obj.content.tag)
Пример #2
0
def test_get_category_map(monkeypatch):
    """get_category_map regular test"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_getcategorymap.xml'))
    shiba_connection = ShibaConnection("test", "test" "https://ws.fr.shopping.rakuten.com")
    marketplace_management = MarketplaceManagement(shiba_connection)

    obj = marketplace_management.get_category_map()
    assert "categorymap" in obj.content.tag
Пример #3
0
def test_get_category_map(monkeypatch):
    """get_category_map regular test"""
    monkeypatch.setattr("requests.get", make_requests_get_mock("sample_getcategorymap.xml"))
    shiba_connection = ShibaConnection("test", "test" "https://ws.sandbox.priceminister.com")
    marketplace_management = MarketplaceManagement(shiba_connection)

    obj = marketplace_management.get_category_map()
    assert "categorymap" in obj.content.tag
Пример #4
0
def test_product_list_bad(monkeypatch):
    """testing get_product_list methods with different queries, with some invalid ones as well"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_productlist_bad.xml'))

    shiba_connection = ShibaConnection("test", "test" "https://ws.fr.shopping.rakuten.com")
    marketplace_management = MarketplaceManagement(shiba_connection)

    product_list = marketplace_management.get_product_list(kw="livre")
    assert "listingresult" in product_list.content.tag
Пример #5
0
def test_get_product_list(monkeypatch):
    """testing get_product_list methods with different queries, with some invalid ones as well"""
    monkeypatch.setattr('requests.get', make_requests_get_mock('sample_getproductlist.xml'))

    shiba_connection = ShibaConnection("test", "test" "https://ws.fr.shopping.rakuten.com")
    marketplace_management = MarketplaceManagement(shiba_connection)

    # TODO: to remove ?
    # with assert_raises(ShibaParameterError):
    #     marketplace_management.get_product_list()

    product_list = marketplace_management.get_product_list(kw="livre")
    assert "listingresult" in product_list.content.tag

    # TODO: to remove ?
    # with assert_raises(ShibaParameterError):
    #     marketplace_management.get_product_list(nbproductsperpage=-15, kw="livre")

    product_list = marketplace_management.get_product_list(kw="informatique", scope="PRICING")
    assert "listingresult" in product_list.content.tag
Пример #6
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 = MarketplaceManagement(ShibaConnection(login, pwd, "https://ws.sandbox.priceminister.com"))