Ejemplo n.º 1
0
 def test_get_all_products(self):
     meli = MeliInterface()
     products = meli.get_all_products()
     assert len(products) > 0
     # first key
     key = next(iter(products))
     assert key.startswith('MLB')
     assert products[key]['id'].startswith('MLB')
Ejemplo n.º 2
0
 def test_get_product(self):
     meli = MeliInterface()
     products = meli.get_all_products_id()
     assert len(products) > 0
     meli_product_id = products[0]
     print(f'Meli product to be get: {meli_product_id}')
     meli_product = meli.get_product(meli_product_id)
     print(f'id: {meli_product["id"]}')
     print(f'title: {meli_product["title"]}')
     print(f'available_quantity: {meli_product["available_quantity"]}')
     print(f'base_price: {meli_product["base_price"]}')
     print(f'price: {meli_product["price"]}')
     assert len(meli_product["title"]) > 0
Ejemplo n.º 3
0
    def test_auth_envs(self):
        # development mode
        meli = str(MeliInterface())
        meli_user = meli.split(':')[0]
        meli_pass = meli.split(':')[1].split('@')[0]
        meli_host = meli.split('@')[1]
        assert meli_user[:3] == 'zun'
        assert meli_pass[:3] == 'sit'
        assert meli_host[:4] == 'http'

        # production mode
        meli = str(MeliInterface('prod'))
        meli_user = meli.split(':')[0]
        meli_pass = meli.split(':')[1].split('@')[0]
        meli_host = meli.split('@')[1]
        assert meli_user[:3] == 'zun'
        assert meli_pass[:3] == 'sit'
        assert meli_host[:4] == 'http'
Ejemplo n.º 4
0
    def test_check_zunka_products_consistence_no_back_reference(self):
        zunka = ZunkaInterface()
        meli = MeliInterface()

        meli_products = loadDic('./json/meli_products.json')
        zunka_products = loadDic('./json/zunka_product_no_back_reference.json')

        # First zunka product.
        zunka_product_id = next(iter(zunka_products))
        # print(f'id: {zunka_product_id}')
        result = zunka.check_zunka_products_consistence(
            zunka_products, meli_products)
        assert zunka_product_id in result['no_back_reference']
Ejemplo n.º 5
0
    def test_check_zunka_products_consistence_product_diff(self):
        zunka = ZunkaInterface()
        meli = MeliInterface()

        meli_products = loadDic('./json/meli_products_diff_title.json')
        zunka_products = loadDic('./json/zunka_product.json')

        # First zunka product.
        zunka_product_id = next(iter(zunka_products))
        # print(f'id: {zunka_product_id}')
        result = zunka.check_zunka_products_consistence(
            zunka_products, meli_products)
        assert zunka_product_id in result['not_equal']
        print(result)
Ejemplo n.º 6
0
    def test_check_meli_products_consistence_product_diff(self):
        zunka = ZunkaInterface()
        meli = MeliInterface()

        meli_products = loadDic(
            './json/meli_product_test_check_meli_products_consistence_diff.json'
        )
        zunka_products = loadDic(
            './json/zunka_product_test_check_meli_products_consistence_diff.json'
        )

        result = zunka.check_meli_products_consistence(meli_products,
                                                       zunka_products)
        assert 'MLB1194944322' in result['not_equal']
        print(result)
Ejemplo n.º 7
0
    def test_update_product(self):
        meli = MeliInterface()
        products = meli.get_active_products()
        assert len(products) > 0
        meli_product = products[0]
        product_id = meli_product["id"]
        product_title = meli_product["title"]
        product_price = meli_product["price"]
        product_qty = meli_product["available_quantity"]
        print(f'\nOriginal product: {product_id}')
        print(f'    title: {product_title}')
        print(f'    price: {product_price}')
        print(f'    available_quantity: {product_qty}')
        assert product_qty > 0
        # Can do the test if product not have stock.
        assert meli_product["available_quantity"] > 0

        # New values.
        new_product_qty = product_qty - 1
        new_product_price = product_price - 1
        print(f'Will be change to: quantity: {new_product_qty}, price: {new_product_price}')

        # Update product.
        meli.update_product(product_id, new_product_price, new_product_qty)
        changed_product = meli.get_product(product_id)
        assert  changed_product["price"] == new_product_price   
        assert  changed_product["available_quantity"] == new_product_qty
        print(f'Changed product: {changed_product["id"]}')
        print(f'    price: {changed_product["price"]}')
        print(f'    available_quantity: {changed_product["available_quantity"]}')

        # Restore product.
        meli.update_product(product_id, product_price, product_qty)
        restored_product = meli.get_product(product_id)
        assert  restored_product["price"] == product_price   
        assert  restored_product["available_quantity"] == product_qty
        print(f'Restored product: {restored_product ["id"]}')
        print(f'    price: {restored_product["price"]}')
        print(f'    available_quantity: {restored_product["available_quantity"]}')
Ejemplo n.º 8
0
    def test_check_meli_products_consistence_no_back_reference(self):
        zunka = ZunkaInterface()
        meli = MeliInterface()

        meli_products = loadDic(
            './json/meli_product_test_check_meli_products_consistence_no_back_reference.json'
        )
        zunka_products = loadDic(
            './json/zunka_product_test_check_meli_products_consistence_no_back_reference.json'
        )

        zunka_product_id = meli_products.get('MLB1194944322').get(
            'seller_custom_field')
        # print(f'id: {zunka_product_id}')
        result = zunka.check_meli_products_consistence(meli_products,
                                                       zunka_products)
        assert zunka_product_id in result['no_back_reference']
Ejemplo n.º 9
0
zunka = ZunkaInterface()
zunka_products = zunka.get_all_products()
#  print(list(zunka_products))

#  debug(f'Zunka products with meli id: {len(zunka_products)}')
debug(f'All Zunka products: {len(zunka_products)}')
#  for key, value in zunka_products.items():
#  print(key)
#  print(value['storeProductTitle'])
#  print('\n')

debug('Temporary finish.')
exit()
print('Not exited!')

meli = MeliInterface()
meli_products = meli.get_active_products()
meli_products = MeliInterface.make_dic_id_product(meli_products)

debug(f'All Meli products: {len(meli_products)}')
#  for key, value in meli_products.items():
#  print(key)
#  print(value)

#  debug('Temporary finish.')
#  exit()
#  print('Not exited!')

# Check zunka products consistence.
check_result_zunka = zunka.check_zunka_products_consistence(
    zunka_products, meli_products)
Ejemplo n.º 10
0
from zunka import ZunkaInterface
from meli import MeliInterface

# set run mode
run_mode = util.get_run_mode()
PROD, TEST, DEV = run_mode['PROD'], run_mode['TEST'], run_mode['DEV']
#  print(f'PROD: {PROD}, TEST: {TEST}, DEV: {DEV}')

#  zunka = ZunkaInterface()
#  zunka_products = zunka.get_all_products_with_meli_id()
#  print(list(zunka_products))
#  for key, value in zunka_products.items():
#  print(key)
#  print(value['storeProductTitle'])

meli = MeliInterface()
print(meli.get_all_products_id())

#  meli_products = meli.get_all_products()

#  print(f'type of: {type(meli_products)}')
#  key = next(iter(meli_products))
#  print(f' First item: {meli_products[key]["id"]}')
#  print(f' First item: {meli_products[key]["title"]}')
#  print(f' First item: {meli_products[key].get("title")}')

#  for key, value in meli_products.items():
#  #  print(key)
#  #  print(value)
#  #  print(value.get('title'))
#  print(f"[{value.get('seller_custom_field')}] - {key} - {value.get('title')}")
Ejemplo n.º 11
0
 def test_get_products_from_ids(self):
     meli = MeliInterface()
     products_id = meli.get_all_products_id()[:4]
     products = meli.get_products_from_ids(products_id)
     assert len(products_id) == len(products)
Ejemplo n.º 12
0
 def test_get_active_products_ids(self):
     meli = MeliInterface()
     ids = meli.get_active_products_ids()
     assert len(ids) > 0
     #  print(json.dumps(products[0], indent=4, sort_keys=True))
     print(f'Products ids: {ids}')
Ejemplo n.º 13
0
 def test_get_active_products(self):
     meli = MeliInterface()
     products = meli.get_active_products()
     assert len(products) > 0
     #  print(json.dumps(products[0], indent=4, sort_keys=True))
     print(f'Products len: {len(products)}')
Ejemplo n.º 14
0
 def test_get_all_products_id(self):
     meli = MeliInterface()
     products = meli.get_all_products_id()
     assert len(products) > 0
Ejemplo n.º 15
0
 def test_get_token_access(self):
     meli = MeliInterface()
     token = meli.get_token_access()
     assert len(token) >= 10