def testPluginIsActiveWhenNoRuns(self): """The plugin should be inactive when there are no runs.""" multiplexer = event_multiplexer.EventMultiplexer() context = base_plugin.TBContext(logdir=self.logdir, multiplexer=multiplexer) plugin = text_plugin.TextPlugin(context) self.assertFalse(plugin.is_active())
def testPluginIsActiveWhenTextRuns(self): """The plugin should be active when there are runs with text.""" multiplexer = event_multiplexer.EventMultiplexer() context = base_plugin.TBContext(logdir=None, multiplexer=multiplexer) plugin = text_plugin.TextPlugin(context) multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() self.assertIsActive(plugin, True)
def setUp(self): self.logdir = self.get_temp_dir() self.generate_testdata() multiplexer = event_multiplexer.EventMultiplexer() multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() context = base_plugin.TBContext(logdir=self.logdir, multiplexer=multiplexer) self.plugin = text_plugin.TextPlugin(context)
def load_plugin(self): self.generate_testdata() multiplexer = event_multiplexer.EventMultiplexer() multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() provider = data_provider.MultiplexerDataProvider( multiplexer, self.logdir) ctx = base_plugin.TBContext(logdir=self.logdir, data_provider=provider) return text_plugin.TextPlugin(ctx)
def testPluginIsActiveWhenRunsButNoText(self): """The plugin should be inactive when there are runs but none has text.""" multiplexer = event_multiplexer.EventMultiplexer() context = base_plugin.TBContext(logdir=None, multiplexer=multiplexer) plugin = text_plugin.TextPlugin(context) logdir = os.path.join(self.get_temp_dir(), 'runs_with_no_text') self.generate_testdata(include_text=False, logdir=logdir) multiplexer.AddRunsFromDirectory(logdir) multiplexer.Reload() self.assertIsActive(plugin, False)
def wrapper(self, *args, **kwargs): if generate_testdata: self.generate_testdata(include_text=include_text) multiplexer = event_multiplexer.EventMultiplexer() multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() with self.subTest("bare multiplexer"): ctx = base_plugin.TBContext(logdir=self.logdir, multiplexer=multiplexer) fn(self, text_plugin.TextPlugin(ctx), *args, **kwargs) with self.subTest("generic data provider"): flags = argparse.Namespace(generic_data="true") provider = data_provider.MultiplexerDataProvider( multiplexer, self.logdir) ctx = base_plugin.TBContext( flags=flags, logdir=self.logdir, multiplexer=multiplexer, data_provider=provider, ) fn(self, text_plugin.TextPlugin(ctx), *args, **kwargs)
def testPluginIsActive(self): multiplexer = event_multiplexer.EventMultiplexer() context = base_plugin.TBContext(logdir=None, multiplexer=multiplexer) plugin = text_plugin.TextPlugin(context) # The plugin is inactive because text summaries are not available. self.assertFalse(plugin.is_active()) multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() # The plugin is active because text summaries are available. self.assertTrue(self.plugin.is_active())
def testPluginIsActiveWhenTextRuns(self): """The plugin should be active when there are runs with text.""" multiplexer = event_multiplexer.EventMultiplexer() context = base_plugin.TBContext(logdir=self.logdir, multiplexer=multiplexer) plugin = text_plugin.TextPlugin(context) multiplexer.AddRunsFromDirectory(self.logdir) multiplexer.Reload() patcher = tf.test.mock.patch('threading.Thread.start', autospec=True) mock = patcher.start() self.addCleanup(patcher.stop) self.assertTrue(plugin.is_active(), True) # Data is available within the multiplexer. No thread should have started # for checking plugin assets data. self.assertFalse(mock.called)