Beispiel #1
0
 def test_serialization_rejects_wrong_version(self):
     info = _make_info()._replace(version="reversion")
     with six.assertRaisesRegex(
         self,
         ValueError,
         "expected 'version' to be '.*', but found: 'reversion'",
     ):
         manager._info_to_string(info)
Beispiel #2
0
 def test_serialization_rejects_bad_types(self):
     bad_time = datetime.datetime.fromtimestamp(1549061116)  # not an int
     info = _make_info()._replace(start_time=bad_time)
     with six.assertRaisesRegex(
             self,
             ValueError,
             r"expected 'start_time' of type.*int.*, but found: datetime\.",
     ):
         manager._info_to_string(info)
Beispiel #3
0
 def test_deserialization_rejects_missing_version(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     del json_value["version"]
     bad_input = json.dumps(json_value)
     with six.assertRaisesRegex(self, ValueError, "incompatible version:"):
         manager._info_from_string(bad_input)
Beispiel #4
0
 def test_deserialization_ignores_extra_keys(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     json_value["unlikely"] = "story"
     bad_input = json.dumps(json_value)
     result = manager._info_from_string(bad_input)
     self.assertIsInstance(result, manager.TensorBoardInfo)
Beispiel #5
0
 def test_deserialization_accepts_future_version(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     json_value["version"] = "99.99.99a20991232"
     input_ = json.dumps(json_value)
     result = manager._info_from_string(input_)
     self.assertEqual(result.version, "99.99.99a20991232")
Beispiel #6
0
 def test_deserialization_rejects_missing_keys(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     del json_value["start_time"]
     bad_input = json.dumps(json_value)
     with six.assertRaisesRegex(self, ValueError,
                                "bad keys on TensorBoardInfo"):
         manager._info_from_string(bad_input)
Beispiel #7
0
 def test_deserialization_rejects_extra_keys(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     json_value["unlikely"] = "story"
     bad_input = json.dumps(json_value)
     with six.assertRaisesRegex(self, ValueError,
                                "bad keys on TensorBoardInfo"):
         manager._info_from_string(bad_input)
Beispiel #8
0
 def test_deserialization_rejects_missing_keys(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     del json_value["start_time"]
     bad_input = json.dumps(json_value)
     with six.assertRaisesRegex(self, ValueError,
                                re.escape("missing keys: ['start_time']")):
         manager._info_from_string(bad_input)
Beispiel #9
0
 def test_deserialization_rejects_missing_version(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     del json_value["version"]
     bad_input = json.dumps(json_value)
     with self.assertRaisesRegex(ValueError,
                                 re.escape("missing keys: ['version']")):
         manager._info_from_string(bad_input)
Beispiel #10
0
 def test_deserialization_rejects_bad_types(self):
     info = _make_info()
     json_value = json.loads(manager._info_to_string(info))
     json_value["start_time"] = "2001-02-03T04:05:06"
     bad_input = json.dumps(json_value)
     with six.assertRaisesRegex(
             self, ValueError,
             "expected 'start_time' of type.*int.*, but found:.*"
             "'2001-02-03T04:05:06'"):
         manager._info_from_string(bad_input)
Beispiel #11
0
 def test_roundtrip_serialization(self):
     # This is also tested indirectly as part of `manager` integration
     # tests, in `test_get_all`.
     info = _make_info()
     also_info = manager._info_from_string(manager._info_to_string(info))
     self.assertEqual(also_info, info)
Beispiel #12
0
 def test_roundtrip_serialization(self):
     # This will also be tested indirectly as part of `manager`
     # integration tests.
     info = _make_info()
     also_info = manager._info_from_string(manager._info_to_string(info))
     self.assertEqual(also_info, info)