Exemplo n.º 1
0
 def setUp(self):
     """
     Set up a PiwikTrackerEcommerce instance
     """
     super(TrackerEcommerceBaseTestCase, self).setUp()
     # Set different IP for each test run
     # TODO also randomize referers etc...
     self.pte = PiwikTrackerEcommerce(self.settings['PIWIK_SITE_ID'],
                                      self.request)
     self.pte.set_api_url(self.settings['PIWIK_TRACKING_API_URL'])
     self.pte.set_ip(self.get_random_ip())
     self.pte.set_token_auth(self.settings['PIWIK_TOKEN_AUTH'])
     self.pte.set_custom_variable(
         5,
         'testsegment',
         self.segment,
     )
     self.pte._set_host("ecommerce.example.com")
     self.pte._set_query_string('')
Exemplo n.º 2
0
 def setUp(self):
     """
     Set up a PiwikTrackerEcommerce instance
     """
     super(TrackerEcommerceBaseTestCase, self).setUp()
     # Set different IP for each test run
     # TODO also randomize referers etc...
     self.pte = PiwikTrackerEcommerce(self.settings['PIWIK_SITE_ID'],
                                      self.request)
     self.pte.set_api_url(self.settings['PIWIK_TRACKING_API_URL'])
     self.pte.set_ip(self.get_random_ip())
     self.pte.set_token_auth(self.settings['PIWIK_TOKEN_AUTH'])
     self.pte.set_custom_variable(
         5,
         'testsegment',
         self.segment,
     )
     self.pte._set_host("ecommerce.example.com")
     self.pte._set_query_string('')
Exemplo n.º 3
0
class TrackerEcommerceBaseTestCase(TrackerVerifyBaseTestCase):
    """
    Base class for the ecommerce tests

    Contains test products.
    """
    products = {
        'book': {
            'sku': '1',
            'name': 'Book',
            'category': ('book category', 'books', ),
            'price': 999,
            'quantity': 3,
        },
        'car': {
            'sku': '2',
            'name': 'Car',
            'category': ('car category', 'cars', ),
            'price': 525,
            'quantity': 3,
        },
        'ball': {
            'sku': '3',
            'name': 'Ball',
            'category': ('ball category', 'balls', ),
            'price': 739,
            'quantity': 7,
        },
    }

    def setUp(self):
        """
        Set up a PiwikTrackerEcommerce instance
        """
        super(TrackerEcommerceBaseTestCase, self).setUp()
        # Set different IP for each test run
        # TODO also randomize referers etc...
        self.pte = PiwikTrackerEcommerce(self.settings['PIWIK_SITE_ID'],
                                         self.request)
        self.pte.set_api_url(self.settings['PIWIK_TRACKING_API_URL'])
        self.pte.set_ip(self.get_random_ip())
        self.pte.set_token_auth(self.settings['PIWIK_TOKEN_AUTH'])
        self.pte.set_custom_variable(
            5,
            'testsegment',
            self.segment,
        )
        self.pte._set_host("ecommerce.example.com")
        self.pte._set_query_string('')

    def get_cv(self, number):
        """
        Get a custom variable from the last visit
        """
        try:
            if sys.version_info[0] >= 3:
                data = json.loads(self.a.send_request().decode('utf-8'))[-1]['actionDetails'][0]['customVariables']
            else:
                data = json.loads(self.a.send_request())[-1]['actionDetails'][0]['customVariables']
        except IndexError:
            print("Request apparently not logged!")
            raise
        try:
            return data[str(number)]['customVariableValue%s' % number]
        except KeyError:
            self.debug(data)
            raise
Exemplo n.º 4
0
class TrackerEcommerceBaseTestCase(TrackerVerifyBaseTestCase):
    """
    Base class for the ecommerce tests

    Contains test products.
    """
    products = {
        'book': {
            'sku': '1',
            'name': 'Book',
            'category': (
                'book category',
                'books',
            ),
            'price': 999,
            'quantity': 3,
        },
        'car': {
            'sku': '2',
            'name': 'Car',
            'category': (
                'car category',
                'cars',
            ),
            'price': 525,
            'quantity': 3,
        },
        'ball': {
            'sku': '3',
            'name': 'Ball',
            'category': (
                'ball category',
                'balls',
            ),
            'price': 739,
            'quantity': 7,
        },
    }

    def setUp(self):
        """
        Set up a PiwikTrackerEcommerce instance
        """
        super(TrackerEcommerceBaseTestCase, self).setUp()
        # Set different IP for each test run
        # TODO also randomize referers etc...
        self.pte = PiwikTrackerEcommerce(self.settings['PIWIK_SITE_ID'],
                                         self.request)
        self.pte.set_api_url(self.settings['PIWIK_TRACKING_API_URL'])
        self.pte.set_ip(self.get_random_ip())
        self.pte.set_token_auth(self.settings['PIWIK_TOKEN_AUTH'])
        self.pte.set_custom_variable(
            5,
            'testsegment',
            self.segment,
        )
        self.pte._set_host("ecommerce.example.com")
        self.pte._set_query_string('')

    def get_cv(self, number):
        """
        Get a custom variable from the last visit
        """
        try:
            if sys.version_info[0] >= 3:
                data = json.loads(self.a.send_request().decode(
                    'utf-8'))[-1]['actionDetails'][0]['customVariables']
            else:
                data = json.loads(self.a.send_request()
                                  )[-1]['actionDetails'][0]['customVariables']
        except IndexError:
            print("Request apparently not logged!")
            raise
        try:
            return data[str(number)]['customVariableValue%s' % number]
        except KeyError:
            self.debug(data)
            raise