Esempio n. 1
0
    def test_should_return_pretty_printed_bson_documents(self):

        # Given a document
        doc = {
            "age":
            26,
            "name":
            "Svetlana",
            "skills": [{
                "skill": "C++",
                "level": 7
            }, {
                "skill": "Python",
                "level": 7
            }]
        }

        # dumps() should return pretty-printed version of the document
        expected = textwrap.dedent("""\
            {
                "age": 26, 
                "name": "Svetlana", 
                "skills": [
                    {
                        "level": 7, 
                        "skill": "C++"
                    }, 
                    {
                        "level": 7, 
                        "skill": "Python"
                    }
                ]
            }""")
        self.maxDiff = None
        self.assertMultiLineEqual(mongofuse.dumps(doc), expected)
Esempio n. 2
0
    def test_should_return_pretty_printed_bson_documents(self):

        # Given a document
        doc = {"age": 26,
               "name": "Svetlana", 
               "skills": [{
                   "skill": "C++",
                   "level": 7
                },
                {
                    "skill": "Python",
                    "level": 7
                }]
            }

        # dumps() should return pretty-printed version of the document
        expected = textwrap.dedent("""\
            {
                "age": 26, 
                "name": "Svetlana", 
                "skills": [
                    {
                        "level": 7, 
                        "skill": "C++"
                    }, 
                    {
                        "level": 7, 
                        "skill": "Python"
                    }
                ]
            }""")
        self.maxDiff = None
        self.assertMultiLineEqual(mongofuse.dumps(doc), expected)
Esempio n. 3
0
    def test_should_encode_datetime_objects(self):

        doc = {"dt": datetime.datetime(2012, 6, 30, 22, 00)}
        expected = textwrap.dedent("""\
                {
                    "dt": ISODate("2012-06-30T22:00:00Z")
                }""")
        self.assertMultiLineEqual(mongofuse.dumps(doc), expected)
Esempio n. 4
0
    def test_should_encode_datetime_objects(self):

        doc = {"dt": datetime.datetime(2012, 6, 30, 22, 00)}
        expected = textwrap.dedent("""\
                {
                    "dt": ISODate("2012-06-30T22:00:00Z")
                }""")
        self.assertMultiLineEqual(mongofuse.dumps(doc), expected)