Skip to content

Commit

Permalink
bug 915246 - add model for AduBySignature
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmer committed Apr 15, 2014
1 parent 43a19fd commit 863219a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
19 changes: 19 additions & 0 deletions webapp-django/crashstats/crashstats/models.py
Expand Up @@ -1471,3 +1471,22 @@ class LagLog(SocorroMiddleware):

# never anything sensitive
API_WHITELIST = None


class AduBySignature(SocorroMiddleware):

URL_PREFIX = '/crashes/adu_by_signature/'
required_params = (
'signature',
'channel',
)

possible_params = (
('start_date', datetime.date),
('end_date', datetime.date),
)

API_WHITELIST = (
'hits',
'total',
)
42 changes: 42 additions & 0 deletions webapp-django/crashstats/crashstats/tests/test_models.py
Expand Up @@ -1492,6 +1492,48 @@ def mocked_get(url, params, **options):
r = api.get()
eq_(r['replicas'], replicas)

@mock.patch('requests.get')
def test_adu_by_signature(self, rget):
model = models.AduBySignature
api = model()

def mocked_get(url, params, **options):
assert '/adu_by_signature/' in url

ok_('signature' in params)
eq_(params['signature'], 'FakeSignature1')

ok_('channel' in params)
eq_(params['channel'], 'nightly')

return Response("""
{
"hits": [
{"build_date": "2014-04-01",
"os_name": "Windows",
"buildid": "20140401000000",
"adu_count": 1,
"crash_count": 1,
"adu_date": "2014-04-01",
"signature": "FakeSignature1",
"channel": "nightly"},
{"build_date": "2014-04-01",
"os_name": "Windows",
"buildid": "20140401000001",
"adu_count": 2,
"crash_count": 2,
"adu_date": "2014-04-01",
"signature": "FakeSignature2",
"channel": "nightly"}],
"total": 2
}
""")

rget.side_effect = mocked_get
r = api.get(signature='FakeSignature1',
channel='nightly')
eq_(r['total'], 2)


class TestModelsWithFileCaching(TestCase):

Expand Down

0 comments on commit 863219a

Please sign in to comment.