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)
751
751
def test_not_found(self):
752
752
self.makeBundle(name='bat')
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)
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)
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)
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)
806
835
class TestAPI3Bundles(TestAPIBundles, API3Mixin):
807
836
"""Test API 3 bundle endpoint."""