~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/views/tests/test_api.py

[r=adeuring,abentley][bug=1199790][author=adeuring] Return dummy data for Charm.last_change and Charm.first_change, if a branch does not have any commits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
    datetime,
9
9
)
10
10
import hashlib
 
11
import json
11
12
 
12
13
from pyramid.httpexceptions import HTTPNotFound
13
14
from webob.etag import ETagMatcher
607
608
        self.assertNotIn('related', data['result']['popular'][0]['metadata'])
608
609
        self.assertNotIn('related', data['result']['featured'][0]['metadata'])
609
610
 
 
611
    def test_charm_with_empty_branch(self):
 
612
        # Empty branches do not have real data for the attributes
 
613
        # first_change and last_change. The view is nevertheless properly
 
614
        # rendered.
 
615
        self.makeCharm(empty_branch=True)
 
616
        result = json.loads(self.get_response('charms').body)['result'][0]
 
617
        # But the returned data does contain only dummy revision related
 
618
        # data.
 
619
        self.assertEqual('0', result['charm']['code_source']['revision'])
 
620
        self.assertEqual('', result['charm']['code_source']['last_log'])
 
621
 
610
622
 
611
623
class TestAPI2Charms(TestAPICharms, API2Mixin):
612
624
    """Test API 2's "charms" endpoint."""