~fabricematrat/charmworld/redirect-charm

« back to all changes in this revision

Viewing changes to charmworld/jobs/tests/test_cstat.py

  • Committer: Tarmac
  • Author(s): Rick Harding
  • Date: 2013-07-01 16:17:27 UTC
  • mfrom: (288.2.3 total-stats)
  • Revision ID: tarmac-20130701161727-0pecnptvuirkuevq
[r=sinzui][bug=1194152][author=rharding] Add support for a total downloads attribute.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
            @staticmethod
33
33
            def send(request):
34
34
                response = Response()
35
 
                response._content = '[["2010-12-24", 4], ["2010-12-25", 1]]'
 
35
                if ('start' in request.url):
 
36
                    response._content = '[["2010-12-24", 4], ["2010-12-25", 1]]'
 
37
                else:
 
38
                    response._content = '[[25]]'
36
39
                return response
37
40
 
38
41
        store.session = FakeSession
39
42
        update_counts(CharmSource(self.db, index_client), store, log)
40
43
        db_charm = self.db.charms.find_one({'_id': charm_id})
41
44
        self.assertEqual(5, db_charm['downloads_in_past_30_days'])
 
45
        self.assertEqual(25, db_charm['downloads'])
42
46
        index_charm = index_client.get(charm_id)
43
47
        self.assertEqual(5, index_charm['downloads_in_past_30_days'])
 
48
        self.assertEqual(25, index_charm['downloads'])
44
49
 
45
50
    def test_update_no_index(self):
46
51
        charm_id, charm = factory.makeCharm(self.db)