Browse Source

Fix 500 error when POSTing a LDP-NR.

Stefano Cossu 6 years ago
parent
commit
d0a76c0569
2 changed files with 20 additions and 1 deletions
  1. 1 1
      lakesuperior/endpoints/ldp.py
  2. 19 0
      tests/endpoints/test_ldp.py

+ 1 - 1
lakesuperior/endpoints/ldp.py

@@ -251,7 +251,7 @@ def post_resource(parent_uid):
     uri = g.tbox.uid_to_uri(uid)
     hdr = {'Location' : uri}
 
-    if mimetype and not is_rdf:
+    if mimetype and rdf_fmt is None:
         hdr['Link'] = '<{0}/fcr:metadata>; rel="describedby"; anchor="{0}"'\
                 .format(uri)
 

+ 19 - 0
tests/endpoints/test_ldp.py

@@ -263,6 +263,25 @@ class TestLdp:
         assert 'Location' in res.headers
 
 
+    def test_post_ldp_nr(self, rnd_img):
+        '''
+        POST a resource with binary payload and verify checksums.
+        '''
+        rnd_img['content'].seek(0)
+        resp = self.client.post('/ldp/', data=rnd_img['content'],
+                headers={
+                    'slug': 'ldpnr03',
+                    'Content-Type': 'image/png',
+                    'Content-Disposition' : 'attachment; filename={}'.format(
+                    rnd_img['filename'])})
+        assert resp.status_code == 201
+
+        resp = self.client.get(
+                '/ldp/ldpnr03', headers={'accept' : 'image/png'})
+        assert resp.status_code == 200
+        assert sha1(resp.data).hexdigest() == rnd_img['hash']
+
+
     def test_post_slug(self):
         '''
         Verify that a POST with slug results in the expected URI only if the