def test_analyse_api_error(ready): ''' Tests exception when API returns error. ''' with pytest.raises(requests.HTTPError): analyze('Actions.getPageUrls', period='day', date=date.today(), expanded=1, is_api=True, token_auth='ridiculous')
def test_track(ready): url = 'http://local.test/' + faker.uri_path() track(url) data = analyze('Actions.getPageUrls', period='day', date=date.today(), expanded=1) t = find_tracking(url, data) assert t is not None, 'No tracking entry found for {}'.format(url)
def test_bulk_track(ready): urls = [('http://local.test/' + faker.uri_path(), datetime.now(), {}) for _ in range(3)] urls.append(('https://local.test/utf8-éèü', datetime.now(), {})) response = bulk_track(*urls) assert response['status'] == 'success' assert response['tracked'] == len(urls) data = analyze('Actions.getPageUrls', period='day', date=date.today(), expanded=1) for (url, _, _) in urls: t = find_tracking(url, data) assert t is not None, 'No tracking entry found for {}'.format(url)
def test_track(ready): ''' Use bulk_track w/ default params which should log to PIWIK_ID_FRONT ''' url = 'http://local.test/' + faker.uri_path() track(url) data = analyze('Actions.getPageUrls', period='day', date=date.today(), expanded=1) t = find_tracking(url, data) assert t is not None, 'No tracking entry found for {}'.format(url)
def count_views(self, day): params = {'period': 'day', 'date': day, 'expanded': 1} for row in analyze('Actions.getPageUrls', **params): log.debug('Got views data...') self.handle_views(row, day)
def populate_rows(self): params = {'period': 'day', 'date': self.day, 'expanded': 1} log.debug('Getting downloads data...') self.get_rows(analyze('Actions.getDownloads', **params)) log.debug('Getting outlinks data...') self.get_rows(analyze('Actions.getOutlinks', **params))