Beispiel #1
0
 def match_default_fixture(self, request):
     partname_str, ext, content_type = request.param
     partname = PackURI(partname_str)
     ct_map = _ContentTypeMap()
     ct_map._add_override(PackURI('/bar/foo.xyz'), 'application/xyz')
     ct_map._add_default(ext, content_type)
     return ct_map, partname, content_type
Beispiel #2
0
 def match_default_fixture(self, request):
     partname_str, ext, content_type = request.param
     partname = PackURI(partname_str)
     ct_map = _ContentTypeMap()
     ct_map._add_override(PackURI("/bar/foo.xyz"), "application/xyz")
     ct_map._add_default(ext, content_type)
     return ct_map, partname, content_type
Beispiel #3
0
 def match_override_fixture(self, request):
     partname_str, should_match_partname_str = request.param
     partname = PackURI(partname_str)
     should_match_partname = PackURI(should_match_partname_str)
     content_type = 'appl/vnd-foobar'
     ct_map = _ContentTypeMap()
     ct_map._add_override(partname, content_type)
     return ct_map, should_match_partname, content_type
Beispiel #4
0
 def match_override_fixture(self, request):
     partname_str, should_match_partname_str = request.param
     partname = PackURI(partname_str)
     should_match_partname = PackURI(should_match_partname_str)
     content_type = "appl/vnd-foobar"
     ct_map = _ContentTypeMap()
     ct_map._add_override(partname, content_type)
     return ct_map, should_match_partname, content_type
Beispiel #5
0
 def it_matches_overrides(self):
     # test data --------------------
     partname = PackURI('/part/name1.xml')
     content_type = 'app/vnd.type1'
     # fixture ----------------------
     ct_map = _ContentTypeMap()
     ct_map._overrides = {partname: content_type}
     # verify -----------------------
     assert ct_map[partname] == content_type
Beispiel #6
0
 def it_should_raise_on_key_not_instance_of_PackURI(self):
     ct_map = _ContentTypeMap()
     ct_map._add_override(PackURI('/part/name1.xml'), 'app/vnd.type1')
     with pytest.raises(KeyError):
         ct_map['/part/name1.xml']
Beispiel #7
0
 def it_should_raise_on_partname_not_found(self):
     ct_map = _ContentTypeMap()
     with pytest.raises(KeyError):
         ct_map[PackURI('/!blat/rhumba.1x&')]
Beispiel #8
0
 def it_should_raise_on_key_not_instance_of_PackURI(self):
     ct_map = _ContentTypeMap()
     ct_map._add_override(PackURI("/part/name1.xml"), "app/vnd.type1")
     with pytest.raises(KeyError):
         ct_map["/part/name1.xml"]
Beispiel #9
0
 def it_should_raise_on_partname_not_found(self):
     ct_map = _ContentTypeMap()
     with pytest.raises(KeyError):
         ct_map[PackURI("/!blat/rhumba.1x&")]
Beispiel #10
0
 def it_should_raise_on_key_not_instance_of_PackURI(self):
     ct_map = _ContentTypeMap()
     ct_map._overrides = {PackURI('/part/name1.xml'): 'app/vnd.type1'}
     with pytest.raises(KeyError):
         ct_map['/part/name1.xml']
Beispiel #11
0
 def it_falls_back_to_defaults(self):
     ct_map = _ContentTypeMap()
     ct_map._overrides = {PackURI('/part/name1.xml'): 'app/vnd.type1'}
     ct_map._defaults = {'.xml': 'application/xml'}
     assert ct_map[PackURI('/part/name2.xml')] == 'application/xml'