def test_store_dict_big(self):
     content = self._get_big_dict()
     dictionary = {'content': content}
     self.assertGreater(len(json.dumps(dictionary, cls=MongoJSONEncoder)), 1000000)
     store_dict(dictionary, {})
     self.assertIsNone(dictionary['content'])
     self.assertEqual(content, fetch_dict(dictionary))
     self.assertLess(len(json.dumps(dictionary, cls=MongoJSONEncoder)), 100)
    def test_small_after_big(self):
        updates = {"content": self._get_big_dict()}
        store_dict(updates, {})
        file_id = updates[FILE_ID]
        self.assertIsNotNone(self.app.storage.get(file_id))

        original = updates
        updates = {"content": {"foo": 1}}
        store_dict(updates, original)

        self.assertIsNone(updates[FILE_ID])
        self.assertEqual(json.dumps({"foo": 1}), updates["content"])
        self.assertIsNone(self.app.storage.get(file_id))
    def test_small_after_big(self):
        updates = {'content': self._get_big_dict()}
        store_dict(updates, {})
        file_id = updates[FILE_ID]
        self.assertIsNotNone(self.app.storage.get(file_id))

        original = updates
        updates = {'content': {'foo': 1}}
        store_dict(updates, original)

        self.assertIsNone(updates[FILE_ID])
        self.assertEqual(json.dumps({'foo': 1}), updates['content'])
        self.assertIsNone(self.app.storage.get(file_id))
 def test_store_big_after_small(self):
     original = {"content": {"foo": 1}}
     updates = {"content": self._get_big_dict()}
     store_dict(updates, original)
     self.assertIsNone(updates["content"])
     self.assertIsNotNone(updates[FILE_ID])
 def test_store_dict_small(self):
     content = {"foo": 1}
     dictionary = {"content": content}
     store_dict(dictionary, {})
     self.assertEqual(json.dumps(content), dictionary.get("content"))
     self.assertEqual(content, fetch_dict(dictionary))
 def test_store_big_after_small(self):
     original = {'content': {'foo': 1}}
     updates = {'content': self._get_big_dict()}
     store_dict(updates, original)
     self.assertIsNone(updates['content'])
     self.assertIsNotNone(updates[FILE_ID])
 def test_store_dict_small(self):
     content = {'foo': 1}
     dictionary = {'content': content}
     store_dict(dictionary, {})
     self.assertEqual(json.dumps(content), dictionary.get('content'))
     self.assertEqual(content, fetch_dict(dictionary))
 def test_store_big_after_small(self):
     original = {'content': {'foo': 1}}
     updates = {'content': self._get_big_dict()}
     store_dict(updates, original)
     self.assertIsNone(updates['content'])
     self.assertIsNotNone(updates[FILE_ID])
 def test_store_dict_small(self):
     content = {'foo': 1}
     dictionary = {'content': content}
     store_dict(dictionary, {})
     self.assertEqual(json.dumps(content), dictionary.get('content'))
     self.assertEqual(content, fetch_dict(dictionary))