def _post_large_bulk_insert(self, offset): """Insert just under than max allowed messages.""" doc = '[{{"body": "{0}", "ttl": 300}}, {{"body": "{1}", "ttl": 120}}]' overhead = len(doc.format("", "")) half_size = (self.limits.max_message_size - overhead) // 2 doc = doc.format(helpers.generate_random_string(half_size), helpers.generate_random_string(half_size + offset)) return self.client.post(data=doc)
def _post_large_bulk_insert(self, offset): """Insert just under than max allowed messages.""" doc = '[{{"body": "{0}", "ttl": 300}}, {{"body": "{1}", "ttl": 120}}]' overhead = len(doc.format('', '')) half_size = (self.limits.max_message_size - overhead) // 2 doc = doc.format(helpers.generate_random_string(half_size), helpers.generate_random_string(half_size + offset)) return self.client.post(data=doc)
def test_message_bulk_insert_oversized(self): """Insert more than max allowed size.""" doc = '[{{"body": "{0}", "ttl": 300}}, {{"body": "{1}", "ttl": 120}}]' overhead = len(doc.format("", "")) half_size = (self.limits.max_message_size - overhead) // 2 doc = doc.format(helpers.generate_random_string(half_size), helpers.generate_random_string(half_size + 1)) result = self.client.post(data=doc) self.assertEqual(result.status_code, 400)
def test_message_bulk_insert_oversized(self): """Insert more than max allowed size.""" doc = '[{{"body": "{0}", "ttl": 300}}, {{"body": "{1}", "ttl": 120}}]' overhead = len(doc.format('', '')) half_size = (self.limits.max_message_size - overhead) // 2 doc = doc.format(helpers.generate_random_string(half_size), helpers.generate_random_string(half_size + 1)) result = self.client.post(data=doc) self.assertEqual(result.status_code, 400)