Esempio n. 1
0
    def test_store_inline_empty_content(self):
        """Assert that inline content storage works when content is empty."""
        request = self.store_request('')
        embedded = validate(request.upload_ticket,
                            handlers_endpoints_v1.UPLOAD_MESSAGES[0])
        key = model.get_entry_key(embedded['n'], embedded['d'])

        # assert that store_inline puts the correct entity into the datastore
        self.call_api('store_inline', self.message_to_dict(request), 200)
        stored = key.get()
        self.assertEqual(key, stored.key)

        # assert that expected (digest, size) pair is generated by stored content
        self.assertEqual(
            (embedded['d'].encode('utf-8'), int(embedded['s'])),
            handlers_endpoints_v1.hash_content(stored.content, embedded['n']))
  def test_store_inline_empty_content(self):
    """Assert that inline content storage works when content is empty."""
    request = self.store_request('')
    embedded = validate(
        request.upload_ticket, handlers_endpoints_v1.UPLOAD_MESSAGES[0])
    key = model.get_entry_key(embedded['n'], embedded['d'])

    # assert that store_inline puts the correct entity into the datastore
    self.call_api(
        'store_inline', self.message_to_dict(request), 200)
    stored = key.get()
    self.assertEqual(key, stored.key)

    # assert that expected (digest, size) pair is generated by stored content
    self.assertEqual(
        (embedded['d'].encode('utf-8'), int(embedded['s'])),
        handlers_endpoints_v1.hash_content(stored.content, embedded['n']))