Exemple #1
0
    def test_find_winning_links__theirs1_to_checkout(self):
        log_str = '''[
    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://ad.theirs1.com/?src=q1w2e3r4",
        "date": "2018-04-03T07:59:13.286000Z"
    }
]'''
        links = fwl(log_str)
        self.assertEqual(links, [])
Exemple #2
0
    def test_find_winning_links__ours_to_checkout(self):
        log_str = '''[
    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://referal.ours.com/?ref=0xc0ffee",
        "date": "2018-04-03T07:59:13.286000Z"
    }
]'''
        links = fwl(log_str)
        self.assertEqual(links, ['https://referal.ours.com/?ref=0xc0ffee'])
Exemple #3
0
    def test_find_winning_links__client1_ours_to_checkout__client2_ours_to_checkout(
            self):
        log_str = '''[
    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://referal.ours.com/?ref=0xc0ffee",
        "date": "2018-04-02T07:59:13.286000Z"
    },
    {
        "client_id": "user16",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://referal.ours.com/?ref=123hexcode",
        "date": "2018-04-03T07:59:13.286000Z"
    }
]'''
        self.assertTrue(('user15', 'https://referal.ours.com/?ref=0xc0ffee'
                         ) in fwl(log_str, client_ids=True))
        self.assertTrue(('user16', 'https://referal.ours.com/?ref=123hexcode'
                         ) in fwl(log_str, client_ids=True))
Exemple #4
0
    def test_find_winning_links__search_engine_to_checkout(self):
        log_str = '''    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://yandex.ru/search/?q=купить+котика",
        "date": "2018-04-03T07:59:13.286000Z"
    }'''
        log_str = '''[
{}
]'''.format(log_str)
        links = fwl(log_str)
        self.assertEqual(links, [])
Exemple #5
0
    def test_find_winning_links__client_ours_to_index_to_products_to_cart_to_checkout(
            self):
        log_str = '''[
    {
        "client_id": "user7",
        "User-Agent": "Chrome 65",
        "document.location": "https://shop.com/",
        "document.referer": "https://referal.ours.com/?ref=0xc0ffee",
        "date": "2018-05-23T18:59:13.286000Z"
    },
    {
        "client_id": "user7",
        "User-Agent": "Chrome 65",
        "document.location": "https://shop.com/products/id?=10",
        "document.referer": "https://shop.com/",
        "date": "2018-05-23T18:59:20.119000Z"
    },
    {
        "client_id": "user7",
        "User-Agent": "Chrome 65",
        "document.location": "https://shop.com/products/id?=25",
        "document.referer": "https://shop.com/products/id?=10",
        "date": "2018-05-23T19:04:20.119000Z"
    },
    {
        "client_id": "user7",
        "User-Agent": "Chrome 65",
        "document.location": "https://shop.com/cart",
        "document.referer": "https://shop.com/products/id?=25",
        "date": "2018-05-23T19:05:13.123000Z"
    },
    {
        "client_id": "user7",
        "User-Agent": "Chrome 65",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://shop.com/cart",
        "date": "2018-05-22T18:05:59.224000Z"
    }
]'''
        self.assertTrue(('user7', 'https://referal.ours.com/?ref=0xc0ffee'
                         ) in fwl(log_str, client_ids=True))
Exemple #6
0
    def test_find_winning_links__ours_to_cart_to_checkout_to_cart_to_checkout(
            self):
        """
        when a client reaches the checkout twice not leaving the shop, the affiliate link she
        came to the shop with is counted twice
        """
        log_str = '''[
    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/cart",
        "document.referer": "https://referal.ours.com/?ref=0xc0ffee",
        "date": "2018-04-02T07:59:13.286000Z"
    },
    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://shop.com/cart",
        "date": "2018-04-03T07:59:13.286000Z"
    },
    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/cart",
        "document.referer": "https://shop.com/checkout",
        "date": "2018-04-04T07:59:13.286000Z"
    },
    {
        "client_id": "user15",
        "User-Agent": "Firefox 59",
        "document.location": "https://shop.com/checkout",
        "document.referer": "https://shop.com/cart",
        "date": "2018-04-05T07:59:13.286000Z"
    }
]'''
        links = fwl(log_str)
        self.assertEqual(links, [
            'https://referal.ours.com/?ref=0xc0ffee',
            'https://referal.ours.com/?ref=0xc0ffee',
        ])