Ejemplo n.º 1
0
 def test_to_json(self):
     paragraph = Paragraph([
         Sentence([
             Verb('go').past_tense().capitalize().bold(),
             Noun.uncountable_noun('water'), Punctuation.PERIOD
         ]),
         Sentence([
             BasicWord.preposition('a'), Pronoun.I, CapitalPronoun.ME,
             BeVerb.AM,
             Punctuation.COMMA.bold()
         ])
     ], Tags([StatusTag.PUNCTUATION_ERRORS]))
     as_dict = Serializer.to_dict(paragraph)
     self.assertEqual(json.dumps(as_dict), Serializer.to_json(paragraph))
Ejemplo n.º 2
0
    def test_from_json(self):
        paragraph = Paragraph([
            Sentence([
                Verb('go').past_tense().capitalize().bold(),
                Noun.uncountable_noun('water'), Punctuation.PERIOD
            ]),
            Sentence([
                BasicWord.preposition('a'), Pronoun.I, CapitalPronoun.ME,
                BeVerb.AM,
                Punctuation.COMMA.bold()
            ])
        ], Tags([StatusTag.RAW]))
        as_json = Serializer.to_json(paragraph)

        self.assertEqual(paragraph, Serializer.from_json(as_json))