Skip to content

Commit

Permalink
test(updates): Test new endpoints
Browse files Browse the repository at this point in the history
Also updates existing tests for old endpoint changes.
  • Loading branch information
bnmajor committed Feb 10, 2022
1 parent 8055c38 commit 9dfc76d
Showing 1 changed file with 59 additions and 2 deletions.
61 changes: 59 additions & 2 deletions test/tensorboard_3d_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@ def testRoutesProvided(self):
"""Tests that the plugin offers the correct routes."""
self.assertIsInstance(self.routes["/index.js"], collections.abc.Callable)
self.assertIsInstance(self.routes["/index.html"], collections.abc.Callable)
self.assertIsInstance(self.routes["/images"], collections.abc.Callable)
self.assertIsInstance(self.routes["/images/current"], collections.abc.Callable)
self.assertIsInstance(self.routes["/images/count"], collections.abc.Callable)
self.assertIsInstance(self.routes["/tags"], collections.abc.Callable)
self.assertIsInstance(self.routes["/saveState"], collections.abc.Callable)
self.assertIsInstance(self.routes["/fetchState"], collections.abc.Callable)


def testNewStyleImagesRouteEager(self):
"""Tests that the /images routes returns correct data."""
self.plugin.is_active()
response = self.server.get("/data/plugin/tensorboard_plugin_3d/images")
response = self.server.get("/data/plugin/tensorboard_plugin_3d/images/current")
self.assertEqual(200, response.status_code)

# Verify that the correct entries are returned.
Expand All @@ -112,6 +115,60 @@ def testRunsRoute(self):
self._DeserializeResponse(response.get_data()),
)

def testImagesCount(self):
self.plugin.is_active()
response = self.server.get("/data/plugin/tensorboard_plugin_3d/images/count")
self.assertEqual(200, response.status_code)
count = self._DeserializeResponse(response.get_data())
self.assertEqual(count['value'], 2)

def testStateSaveAndFetch(self):
self.plugin.is_active()
test_state = {
'annotationsEnabled': True,
'axesEnabled': False,
'actorContext': {
'blendMode': 'composite',
'volumeSampleDistance': 0.2
}
}
response = self.server.put(
"/data/plugin/tensorboard_plugin_3d/saveState",
data=json.dumps(test_state),
headers={'Content-type': 'application/json'}
)
self.assertEqual(200, response.status_code)
response = self.server.get("/data/plugin/tensorboard_plugin_3d/fetchState")
self.assertEqual(200, response.status_code)
self.assertDictEqual(test_state, self._DeserializeResponse(response.get_data()))
updates = {
'annotationsEnabled': False,
'actorContext': {
'blendMode': 'maximum',
}
}
response = self.server.put(
"/data/plugin/tensorboard_plugin_3d/saveState",
data=json.dumps(updates),
headers={'Content-type': 'application/json'}
)
self.assertEqual(200, response.status_code)
response = self.server.get("/data/plugin/tensorboard_plugin_3d/fetchState")
self.assertEqual(200, response.status_code)
self.assertDictEqual(
{
'annotationsEnabled': False,
'axesEnabled': False,
'actorContext': {
'blendMode': 'maximum',
'volumeSampleDistance': 0.2
}
},
self._DeserializeResponse(response.get_data())
)




if __name__ == "__main__":
tf.test.main()

0 comments on commit 9dfc76d

Please sign in to comment.