def test_view_api(self): """ Test some basic properties of the view api """ job = setup_capture_job(self.shark) clip = create_trace_clip(self.shark, job) columns, filters = setup_defaults() with self.shark.create_view( clip, columns, filters, name='test_view_on_api') as v: legend = v.get_legend() for col in legend: # make sure we have name and description attributes self.assertTrue(col['name']) self.assertTrue(col['description']) for row in v.get_data(): self.assertTrue(isinstance(row['t'], datetime.datetime)) for val in row['vals']: self.assertEqual(len(val), len(legend)) # do an aggregated get_data() rows = v.get_data(aggregated=True) if len(rows) == 0: logger.warn('no data in view, cannot test aggregated get') self.assertTrue(len(rows) == 0 or len(rows) == 1)
def test_view_api(self): """ Test some basic properties of the view api """ job = setup_capture_job(self.shark) clip = create_trace_clip(self.shark, job) columns, filters = setup_defaults() with self.shark.create_view(clip, columns, filters, name='test_view_on_api') as v: legend = v.get_legend() for col in legend: # make sure we have name and description attributes self.assertTrue(col['name']) self.assertTrue(col['description']) for row in v.get_data(): self.assertTrue(isinstance(row['t'], datetime.datetime)) for val in row['vals']: self.assertEqual(len(val), len(legend)) # do an aggregated get_data() rows = v.get_data(aggregated=True) if len(rows) == 0: logger.warn('no data in view, cannot test aggregated get') self.assertTrue(len(rows) == 0 or len(rows) == 1)
def test_async_view(self): job = setup_capture_job(self.shark) clip = create_trace_clip(self.shark, job) columns, filters = setup_defaults() with self.shark.create_view(clip, columns, filters, sync=False, name='test_async_view') as v: while v.get_progress() < 100: time.sleep(1)
def test_create_view_from_template(self): job = setup_capture_job(self.shark) clip = create_trace_clip(self.shark, job) with open(os.path.join(HERE, 'view-example.json')) as f: template = f.read() with self.shark.create_view_from_template(clip, template) as v: pass
def test_view_on_clip(self): """ Test creating a view on a trace clip """ job = setup_capture_job(self.shark) clip = create_trace_clip(self.shark, job) columns, filters = setup_defaults() with self.shark.create_view(clip, columns, None, name='test_view_on_clip') as view: data = view.get_data() self.assertTrue(len(data) >= 0) self.assertTrue( view.config['input_source']['path'].startswith('clip'))
def test_view_on_clip(self): """ Test creating a view on a trace clip """ job = setup_capture_job(self.shark) clip = create_trace_clip(self.shark, job) columns, filters = setup_defaults() with self.shark.create_view( clip, columns, None, name='test_view_on_clip') as view: data = view.get_data() self.assertTrue(len(data) >= 0) self.assertTrue( view.config['input_source']['path'].startswith('clip'))