Example #1
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_product_categories(id='18')
        assert type(obj) == ProductCategory and obj.id == 18

        obj.refresh()
        assert type(obj) == ProductCategory and obj.id == 18
Example #2
0
    def test_api_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_coupons()
        assert all(type(x) == Coupon for x in obj)

        obj = api.get_coupons(id='112')
        assert type(obj) == Coupon and obj.id == 112
Example #3
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_order_notes(order_id='97', id='108')
        assert type(obj) == OrderNote and obj.id == 108

        obj.refresh()
        assert type(obj) == OrderNote and obj.id == 108
Example #4
0
    def test_api_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_product_attribute_terms(1)
        assert all(type(x) == ProductAttributeTerm for x in obj)

        obj = api.get_product_attribute_terms(1, 26)
        assert type(obj) == ProductAttributeTerm and obj.id == 26
Example #5
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_product_attribute_terms(1, 26)
        assert type(obj) == ProductAttributeTerm and obj.id == 26

        obj.refresh()
        assert type(obj) == ProductAttributeTerm and obj.id == 26
Example #6
0
    def test_api_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_refunds(order_id='97')
        assert all(type(x) == Refund for x in obj)

        obj = api.get_refunds(order_id='97', id='141')
        assert type(obj) == Refund and obj.id == 141
Example #7
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_refunds(order_id='97', id='141')
        assert type(obj) == Refund and obj.id == 141

        obj.refresh()
        assert type(obj) == Refund and obj.id == 141
Example #8
0
    def test_api_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_orders()
        assert all(type(x) == Order for x in obj)

        obj = api.get_orders(id='97')
        assert type(obj) == Order and obj.id == 97
Example #9
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_payment_gateways(id='bacs')
        assert type(obj) == PaymentGateway and obj.id == 'bacs'

        obj.refresh()
        assert type(obj) == PaymentGateway and obj.id == 'bacs'
Example #10
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_customers(id='4')
        assert type(obj) == Customer and obj.id == 4

        obj.refresh()
        assert type(obj) == Customer and obj.id == 4
Example #11
0
    def test_api_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_payment_gateways()
        assert all(type(x) == PaymentGateway for x in obj)

        obj = api.get_payment_gateways(id='bacs')
        assert type(obj) == PaymentGateway and obj.id == 'bacs'
Example #12
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_orders(id='97')
        assert type(obj) == Order and obj.id == 97

        obj.refresh()
        assert type(obj) == Order and obj.id == 97
Example #13
0
    def test_object_delete(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_product_attributes(1)
        assert type(obj) == ProductAttribute and obj.id == 1

        obj = obj.delete()
        assert type(obj) == ProductAttribute and obj.id == 1
Example #14
0
    def test_api_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_product_categories()
        assert all(type(x) == ProductCategory for x in obj)

        obj = api.get_product_categories(id='18')
        assert type(obj) == ProductCategory and obj.id == 18
Example #15
0
    def test_object_refresh(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_coupons(id='112')
        assert type(obj) == Coupon and obj.id == 112

        obj.refresh()
        assert type(obj) == Coupon and obj.id == 112
Example #16
0
    def test_api_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.get_order_notes(order_id='97')
        assert all(type(x) == OrderNote for x in obj)

        obj = api.get_order_notes(order_id='97', id='108')
        assert type(obj) == OrderNote and obj.id == 108
Example #17
0
def create_xml():
    requests_cache.clear()
    api = Api(settings.WOO_HOST,
              settings.WOO_CONSUMER_KEY,
              settings.WOO_CONSUMER_SECRET,
              console_logs=False)
    config = json.load(open(settings.XML_CONFIG_FILENAME))
    print("\033[95m[Feed XML] Getting shipping methods...\033[0m")
    utils.default_shippings.clear()
    utils.default_tax_rates.clear()
    shipping_zones = api.get_shipping_zones()
    for zone in shipping_zones:
        zone_locations = api.get_shipping_zone_locations(
            shipping_zone_id=zone.id)
        zone_methods = api.get_shipping_zone_methods(shipping_zone_id=zone.id)
        for location in zone_locations:
            for method in zone_methods:
                utils.default_shippings.append(
                    utils.get_shipping_method(method, location))
    print("\033[95m[Feed XML] Getting tax rates...\033[0m")
    taxes = get_tax_rates(api)
    for config_file_name, config_file in config.items():
        config_file_languages = config_file.get('languages')
        config_file_types = config_file.get('types')

        if config_file_languages and config_file_types:
            for language_file, languages_in_file in config_file_languages.items(
            ):
                languages_in_file = [languages_in_file] if not isinstance(
                    languages_in_file, list) else languages_in_file

                elements = []
                for language in languages_in_file:
                    print((
                        "\033[95m[Feed XML] Getting products in language '%s'...\033[0m"
                    ) % language)
                    if 'variation' in config_file_types:
                        elements.extend(
                            get_products_and_variations(api, language))
                    else:
                        elements.extend(get_products(api, language))

                config_file_path = config_file_name.split('/')
                config_file_directory = ('/').join(['feeds'] +
                                                   config_file_path[:-1])
                print((
                    "\033[95m[Feed XML] Generating '%s/%s_%s_%s.xml'...\033[0m"
                ) % (config_file_directory, settings.XML_FEED_FILENAME,
                     language_file, config_file_path[-1]))
                selected_products = filter(
                    lambda product: product.type in config_file_types.keys(),
                    elements)
                write_xml(selected_products, language_file, config_file_path,
                          config_file_types)
Example #18
0
    def test_object_update(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = ProductCategory.get_product_categories(api, id='18')
        assert type(obj) == ProductCategory and obj.id == 18

        obj = obj.update()
        assert type(obj) == ProductCategory and obj.id == 18
Example #19
0
    def test_object_update(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = Coupon.get_coupons(api, id='112')
        assert type(obj) == Coupon and obj.id == 112

        obj = obj.update()
        assert type(obj) == Coupon and obj.id == 112
Example #20
0
    def test_classmethod_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = ProductAttribute.get_product_attributes(api)
        assert all(type(x) == ProductAttribute for x in obj)

        obj = ProductAttribute.get_product_attributes(api, 1)
        assert type(obj) == ProductAttribute and obj.id == 1
Example #21
0
    def test_object_update(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = Customer.get_customers(api, id='4')
        assert type(obj) == Customer and obj.id == 4

        obj = obj.update()
        assert type(obj) == Customer and obj.id == 4
Example #22
0
    def test_object_update(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = Order.get_orders(api, id='97')
        assert type(obj) == Order and obj.id == 97

        obj = obj.update()
        assert type(obj) == Order and obj.id == 97
Example #23
0
    def test_classmethod_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = Order.get_orders(api)
        assert all(type(x) == Order for x in obj)

        obj = Order.get_orders(api, id='97')
        assert type(obj) == Order and obj.id == 97
Example #24
0
    def test_object_update(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = PaymentGateway.get_payment_gateways(api, id='bacs')
        assert type(obj) == PaymentGateway and obj.id == 'bacs'

        obj = obj.update()
        assert type(obj) == PaymentGateway and obj.id == 'bacs'
Example #25
0
    def test_classmethod_get(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = Coupon.get_coupons(api)
        assert all(type(x) == Coupon for x in obj)

        obj = Coupon.get_coupons(api, id='112')
        assert type(obj) == Coupon and obj.id == 112
Example #26
0
    def test_classmethod_delete(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = ProductCategory.delete_product_category(api, id='18')
        assert type(obj) == ProductCategory and obj.id == 18
Example #27
0
    def test_classmethod_post(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = ProductCategory.create_product_category(api)
        assert type(obj) == ProductCategory
Example #28
0
    def test_api_put(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.update_product_category(id='18')
        assert type(obj) == ProductCategory and obj.id == 18
Example #29
0
    def test_api_post(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = api.create_product_category()
        assert type(obj) == ProductCategory
Example #30
0
    def test_classmethod_delete(self, func):
        api = Api('', 'fake_consumer_key', 'fake_consumer_secret')

        obj = Order.delete_order(api, id='97')
        assert type(obj) == Order and obj.id == 97