def test_get(self): impl = ADI(config=self.config) assert_raises( MissingArgumentError, impl.get ) start = self.date - datetime.timedelta(days=1) end = self.date stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['42'], platforms=['Linux', 'Windows'], ) eq_(stats['hits'], []) eq_(stats['total'], 0) stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['40.0'], platforms=['Linux', 'Windows'], ) eq_(stats['total'], 1) hit, = stats['hits'] eq_(hit, { 'adi_count': 64L + 16L, 'date': start.date(), 'version': '40.0', 'build_type': 'release' })
def test_get(self): impl = ADI(config=self.config) assert_raises(MissingArgumentError, impl.get) start = self.date - datetime.timedelta(days=1) end = self.date stats = impl.get(start_date=start, end_date=end, product='Firefox', version='42') eq_(stats['hits'], []) eq_(stats['total'], 0) stats = impl.get(start_date=start, end_date=end, product='Firefox', version='40') start_formatted = start.strftime('%Y-%m-%d') eq_(stats['total'], 4) hits = stats['hits'] # Because the results come back in no particular order, # to make it easier to compare, sort by something predictable. hits.sort(key=lambda x: x['adi_count']) eq_( stats['hits'][0], { 'adi_count': 16L, 'date': start_formatted, 'product': 'Firefox', 'version': '40', 'platform': 'Linux', 'release_channel': 'release' })
def test_get(self): impl = ADI(config=self.config) assert_raises(MissingArgumentError, impl.get) start = self.date - datetime.timedelta(days=1) end = self.date stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['42'], platforms=['Linux', 'Windows'], ) eq_(stats['hits'], []) eq_(stats['total'], 0) stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['40.0'], platforms=['Linux', 'Windows'], ) eq_(stats['total'], 1) hit, = stats['hits'] eq_( hit, { 'adi_count': 64L + 16L, 'date': start.date(), 'version': '40.0', 'build_type': 'release' })
def test_get(self): impl = ADI(config=self.config) with pytest.raises(MissingArgumentError): impl.get() start = self.date - datetime.timedelta(days=1) end = self.date stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['42'], platforms=['Linux', 'Windows'], ) assert stats['hits'] == [] assert stats['total'] == 0 stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['40.0'], platforms=['Linux', 'Windows'], ) assert stats['total'] == 1 hit, = stats['hits'] expected = { 'adi_count': 64L + 16L, 'date': start.date(), 'version': '40.0', 'build_type': 'release' } assert hit == expected stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['39.0b'], platforms=['Linux', 'Windows'], ) assert stats['total'] == 1 hit, = stats['hits'] expected = { 'adi_count': 4 + 1L, 'date': start.date(), 'version': '39.0b1', 'build_type': 'release' } assert hit == expected stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['39.0b', '40.0'], platforms=['Linux', 'Windows'], ) assert stats['total'] == 2
def test_get(self): impl = ADI(config=self.config) with pytest.raises(MissingArgumentError): impl.get() start = self.date - datetime.timedelta(days=1) end = self.date stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['42'], platforms=['Linux', 'Windows'], ) assert stats['hits'] == [] assert stats['total'] == 0 stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['40.0'], platforms=['Linux', 'Windows'], ) assert stats['total'] == 1 hit, = stats['hits'] expected = { 'adi_count': 64 + 16, 'date': start.date(), 'version': '40.0', 'build_type': 'release' } assert hit == expected stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['39.0b'], platforms=['Linux', 'Windows'], ) assert stats['total'] == 1 hit, = stats['hits'] expected = { 'adi_count': 4 + 1, 'date': start.date(), 'version': '39.0b1', 'build_type': 'release' } assert hit == expected stats = impl.get( start_date=start, end_date=end, product='Firefox', versions=['39.0b', '40.0'], platforms=['Linux', 'Windows'], ) assert stats['total'] == 2
def test_get(self): impl = ADI(config=self.config) assert_raises( MissingArgumentError, impl.get ) start = self.date - datetime.timedelta(days=1) end = self.date stats = impl.get( start_date=start, end_date=end, product='Firefox', version='42' ) eq_(stats['hits'], []) eq_(stats['total'], 0) stats = impl.get( start_date=start, end_date=end, product='Firefox', version='40' ) start_formatted = start.strftime('%Y-%m-%d') eq_(stats['total'], 4) hits = stats['hits'] # Because the results come back in no particular order, # to make it easier to compare, sort by something predictable. hits.sort(key=lambda x: x['adi_count']) eq_(stats['hits'][0], { 'adi_count': 16L, 'date': start_formatted, 'product': 'Firefox', 'version': '40', 'platform': 'Linux', 'release_channel': 'release' })