Example #1
0
 def test_TimeSeries_serialization(self):
     series2 = TimeSeries(**_loads(_dumps(self.series)))
     self.assertEqual(
         self.series,
         series2,
         "Failed to properly recreate the object." "Expected: %s\nReceived: %s" % (self.series, series2),
     )
Example #2
0
 def test_Range_serialization(self):
     chord2 = Range(**_loads(_dumps(self.chord)))
     self.assertEqual(
         self.chord,
         chord2,
         "Failed to properly recreate the object." "Expected: %s\nReceived: %s" % (self.chord, chord2),
     )
Example #3
0
 def test_Event_serialization(self):
     event2 = Event(**_loads(_dumps(self.event)))
     self.assertEqual(
         self.event,
         event2,
         "Failed to properly recreate the object." "Expected: %s\nReceived: %s" % (self.event, event2),
     )
Example #4
0
 def test_TimeSeriesAnnotation_serialization(self):
     """Verify XAnnotation can be deserialized without a class wrapper."""
     annot2 = _loads(_dumps(self.series_annot))
     self.assertEqual(
         self.series_annot,
         annot2,
         "Failed to properly recreate the object." "Expected: %s\nReceived: %s" % (self.series_annot, annot2),
     )
Example #5
0
 def test_RangeAnnotation_serialization(self):
     # Test that Annotations can be deserialized without a class wrapper.
     annot2 = _loads(_dumps(self.range_annot))
     self.assertEqual(
         self.range_annot,
         annot2,
         "Failed to properly recreate the object." "Expected:\n%s\nReceived:\n%s" % (self.range_annot, annot2),
     )
Example #6
0
 def test_JAMS_serialization(self):
     jam = JAMS(
         beat=[self.event_annot],
         chord=[self.range_annot],
         tag=[self.obs_annot],
         melody=[self.series_annot],
         file_metadata=self.fmeta,
         sandbox=self.sandbox,
     )
     jam2 = JAMS(**_loads(_dumps(jam)))
     self.assertEqual(
         jam, jam2, "Failed to properly recreate the JAMS object." "Expected: %s\nReceived: %s" % (jam, jam2)
     )
Example #7
0
    def test_JObject_serialization(self):
        # JObjects do not serialize Nones, private vars (_xxx), or empty strs.
        self.assertEqual(self.jobj.__json__, dict(a=1), "Failed to properly serialize.")

        # Verify pass-through loop.
        jobj2 = JObject(**_loads(_dumps(self.jobj)))
        self.assertEqual(
            self.jobj,
            jobj2,
            "Failed to properly recreate the object." "Expected: %s\nReceived: %s" % (self.jobj, jobj2),
        )

        self.jobj.e = 1234
        self.assertNotEqual(
            self.jobj,
            jobj2,
            "Assigned attribute failed to propagate." "Expected: %s\nReceived: %s" % (self.jobj, jobj2),
        )
Example #8
0
 def test_Observation_serialization(self):
     obs2 = Observation(**_loads(_dumps(self.obs)))
     self.assertEqual(
         self.obs, obs2, "Failed to properly recreate the object." "Expected: %s\nReceived: %s" % (self.obs, obs2)
     )