~rharding/charmworld/bundle-metadata

« back to all changes in this revision

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

  • Committer: Rick Harding
  • Date: 2013-10-03 16:47:19 UTC
  • mfrom: (401.1.3 bundle-metadata)
  • Revision ID: rick.harding@canonical.com-20131003164719-ccyvs5zomnkkh7ii
Sync with desktop

Show diffs side-by-side

added added

removed removed

Lines of Context:
745
745
 
746
746
    def test_invalid_path(self):
747
747
        self.makeBundle(name='bat')
748
 
        with self.assertRaises(HTTPNotFound):
749
 
            self.get_response('bundle', 'foo')
 
748
        response = self.get_response('bundle', 'foo')
 
749
        self.assertEqual(404, response.status_code)
750
750
 
751
751
    def test_not_found(self):
752
752
        self.makeBundle(name='bat')
802
802
                u'title': u'',
803
803
            })
804
804
 
 
805
    def test_extracting_bundle_id_with_trailing(self):
 
806
        # If there are trailing characters after the bundle ID,
 
807
        # they are returned in "trailing".
 
808
        bundle_id, trailing, bits = self.api_class._parse_bundle_id(
 
809
            '~bac/byobu/4/bat/file/README'.split('/'))
 
810
        self.assertEqual('~bac/byobu/4/bat', bundle_id)
 
811
        self.assertEqual('file/README', trailing)
 
812
 
 
813
        bundle_id, trailing, bits = self.api_class._parse_bundle_id(
 
814
            'byobu/4/bat/file/README'.split('/'))
 
815
        self.assertEqual('byobu/4/bat', bundle_id)
 
816
        self.assertEqual('file/README', trailing)
 
817
 
 
818
        bundle_id, trailing, bits = self.api_class._parse_bundle_id(
 
819
            'byobu/bat/file/README'.split('/'))
 
820
        self.assertEqual('byobu/bat', bundle_id)
 
821
        self.assertEqual('file/README', trailing)
 
822
 
 
823
    def test_bundle_readme(self):
 
824
        # Test that we can store a readme file and get it back out in a
 
825
        # response with the url bundle/id/file/README or something like that.
 
826
        bundle = self.makeBundle(
 
827
            name='bat', owner='bac',
 
828
            basket_with_rev='byobu/4', with_basket=True)
 
829
        factory.make_bundle_file(self.db, bundle, u'README', 'Test Content')
 
830
        response = self.get_response('bundle', '~bac/byobu/4/bat/file/README')
 
831
        self.assertEqual('Test Content', response.body)
 
832
        self.assertEqual(u'text/plain', response.content_type)
 
833
 
805
834
 
806
835
class TestAPI3Bundles(TestAPIBundles, API3Mixin):
807
836
    """Test API 3 bundle endpoint."""