def test_to_str(self): persist = AutoQueuePersist() persist.add_pattern(AutoQueuePattern(pattern="one")) persist.add_pattern(AutoQueuePattern(pattern="two")) persist.add_pattern(AutoQueuePattern(pattern="th ree")) persist.add_pattern(AutoQueuePattern(pattern="fo.ur")) persist.add_pattern(AutoQueuePattern(pattern="fi\"ve")) persist.add_pattern(AutoQueuePattern(pattern="si'x")) print(persist.to_str()) dct = json.loads(persist.to_str()) self.assertTrue("patterns" in dct) self.assertEqual([ AutoQueuePattern(pattern="one").to_str(), AutoQueuePattern(pattern="two").to_str(), AutoQueuePattern(pattern="th ree").to_str(), AutoQueuePattern(pattern="fo.ur").to_str(), AutoQueuePattern(pattern="fi\"ve").to_str(), AutoQueuePattern(pattern="si'x").to_str() ], dct["patterns"])
def test_to_and_from_str(self): persist = AutoQueuePersist() persist.add_pattern(AutoQueuePattern(pattern="one")) persist.add_pattern(AutoQueuePattern(pattern="two")) persist.add_pattern(AutoQueuePattern(pattern="th ree")) persist.add_pattern(AutoQueuePattern(pattern="fo.ur")) persist.add_pattern(AutoQueuePattern(pattern="fi\"ve")) persist.add_pattern(AutoQueuePattern(pattern="si'x")) persist_actual = AutoQueuePersist.from_str(persist.to_str()) self.assertEqual(persist.patterns, persist_actual.patterns)