コード例 #1
0
 def test_when_server_returns_invalid_data(self):
     server = FakeJoule()
     server.response = "notjson"
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(main, ['module', 'list'])
     self.assertTrue('Error' in result.output)
     self.assertEqual(result.exit_code, 1)
     self.stop_server()
コード例 #2
0
 def test_when_server_returns_error_code(self):
     server = FakeJoule()
     error_msg = "test error"
     error_code = 500
     server.response = error_msg
     server.http_code = error_code
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(main, ['module', 'list'])
     self.assertTrue('%d' % error_code in result.output)
     self.assertTrue(error_msg in result.output)
     self.assertEqual(result.exit_code, 1)
     self.stop_server()
コード例 #3
0
ファイル: test_annotation.py プロジェクト: wattsworth/joule
 def test_when_server_returns_error_code(self):
     server = FakeJoule()
     server.response = "test error"
     server.http_code = 500
     server.stub_annotation = True
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(main,
                            ['stream', 'annotations', 'folder/stream'])
     self.assertIn('500', result.output)
     self.assertIn("test error", result.output)
     self.assertEqual(result.exit_code, 1)
     self.stop_server()
コード例 #4
0
ファイル: test_list.py プロジェクト: wattsworth/joule
 def test_lists_streams_with_options(self):
     server = FakeJoule()
     with open(FOLDER_LIST, 'r') as f:
         server.response = f.read()
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(main, ['folder', 'list', '-s', '-l'])
     self.assertEqual(result.exit_code, 0)
     output = result.output
     # check for the augmented legend
     self.assertTrue("configured" in output)
     # check for layout strings
     self.assertTrue("float32_3" in output)
     self.stop_server()
コード例 #5
0
ファイル: test_annotation.py プロジェクト: wattsworth/joule
 def test_reteives_time_bounded_annotations(self):
     server = FakeJoule()
     with open(ANNOTATION_LIST, 'r') as f:
         server.response = f.read()
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(main, [
         'stream', 'annotations', '/my/stream', '--start',
         '28 Jun 2019 16:00', '--end', '29 Jun 2019 16:00'
     ])
     self.assertEqual(result.exit_code, 0)
     query_params = self.msgs.get()
     self.assertEqual(query_params["start"], "1561752000000000")
     self.assertEqual(query_params["end"], "1561838400000000")
     self.stop_server()
コード例 #6
0
ファイル: test_annotation.py プロジェクト: wattsworth/joule
 def test_lists_all_annotations_table(self):
     server = FakeJoule()
     with open(ANNOTATION_LIST, 'r') as f:
         server.response = f.read()
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(main, ['stream', 'annotations', '/my/stream'])
     self.assertEqual(result.exit_code, 0)
     output = result.output
     # check for a few lines in the table
     self.assertIn("Instant", output)
     # timestamps should be displayed as dates
     self.assertNotIn("1561753681898272", output)
     self.assertIn("Fri, 28 Jun 2019 16:05:47", output)
     self.stop_server()
コード例 #7
0
ファイル: test_list.py プロジェクト: wattsworth/joule
 def test_lists_folders(self):
     server = FakeJoule()
     with open(FOLDER_LIST, 'r') as f:
         server.response = f.read()
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(main, ['folder', 'list'])
     self.assertEqual(result.exit_code, 0)
     output = result.output
     # make sure the folders are listed
     for folder in ['basic', 'aux', 'event', 'sensors']:
         self.assertTrue(folder in output)
     # make sure the data streams are listed
     for stream in ['Accel', 'Encoder', 'Gyro']:
         self.assertTrue(stream in output)
     # make sure the event streams are listed
     for stream in ['events0', 'events1', 'events2']:
         self.assertTrue(stream in output)
     # should  check for layout strings
     self.assertFalse("float32_3" in output)
     self.stop_server()
コード例 #8
0
ファイル: test_annotation.py プロジェクト: wattsworth/joule
 def test_lists_annotations_csv(self):
     server = FakeJoule()
     with open(ANNOTATION_LIST, 'r') as f:
         server.response = f.read()
     self.start_server(server)
     runner = CliRunner()
     result = runner.invoke(
         main, ['stream', 'annotations', '/my/stream', '--csv'])
     self._assert_no_error(result)
     output = result.output
     lines = output.split("\n")
     reader = csv.reader(lines[1:])
     annotations = []
     for row in reader:
         annotations.append(row)
     # first annotation is an event
     self.assertEqual(
         ['Instant', 'instant temperature', '1561752347819968'],
         annotations[0])
     # second annoation is a range with no comment
     self.assertEqual(
         ['hot!!!', '', '1561861116610000', '1561862838572000'],
         annotations[1])
     self.stop_server()