Ejemplo n.º 1
0
    def test_mist_cli_list_subcommands(self):
        mist_app = app.MistApp()
        mist_app.workers = MagicMock(return_value=[
            models.Worker('test-worker-id', 'localhost:0', 'spark-ui')
        ])
        mist_app.contexts = MagicMock(return_value=[models.Context('foo')])
        mist_app.jobs = MagicMock(return_value=[
            models.Job('test-job-id', 'test', 'foo', 'cli', 'started')
        ])
        mist_app.functions = MagicMock(
            return_value=[models.Function('test', 'Test', 'foo')])

        def invoke_cmd(cmd):
            return self.runner.invoke(cmd, catch_exceptions=True, obj=mist_app)

        w_res = invoke_cmd(cli.list_workers)
        e_res = invoke_cmd(cli.list_functions)
        j_res = invoke_cmd(cli.list_jobs)
        c_res = invoke_cmd(cli.list_contexts)

        self.assertEqual(w_res.exit_code, 0)
        self.assertEqual(j_res.exit_code, 0)
        self.assertEqual(c_res.exit_code, 0)
        self.assertEqual(e_res.exit_code, 0)

        self.assertTrue('localhost:0' in w_res.output)
        self.assertTrue('test-job-id' in j_res.output)
        self.assertTrue('Test' in e_res.output)
        self.assertTrue('foo' in c_res.output)
Ejemplo n.º 2
0
    def test_worker_to_json(self):
        worker = models.Worker('test', 'akka.tcp://localhost:2551/', 'http://192.168.0.1:4040/')
        res = worker.to_json()

        self.assertTrue('name' in res)
        self.assertTrue('address' in res)
        self.assertTrue('sparkUi' in res)
Ejemplo n.º 3
0
 def test_worker_create(self):
     worker = models.Worker('test', 'akka.tcp://localhost:2551/', 'http://192.168.0.1:4040/')
     self.assertEqual(worker.name, 'test')
     self.assertEqual(worker.address, 'akka.tcp://localhost:2551/')
     self.assertEqual(worker.spark_ui, 'http://192.168.0.1:4040/')
Ejemplo n.º 4
0
 def test_worker_to_row(self):
     worker = models.Worker('test', 'akka.tcp://localhost:2551/', 'http://192.168.0.1:4040/')
     row = models.Worker.to_row(worker)
     self.assertListEqual(row, ['test', 'akka.tcp://localhost:2551/', 'http://192.168.0.1:4040/'])