コード例 #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)
コード例 #2
0
 def test_job_to_row(self):
     job = models.Job('test', 'foo', 'bar', 'http', 'finished', 'test', 0)
     row = models.Job.to_row(job)
     self.assertListEqual(row, [
         'test',
         str(datetime.datetime.fromtimestamp(0)), 'bar', 'test', 'foo',
         'http', 'finished'
     ])
コード例 #3
0
 def test_job_create(self):
     job = models.Job('test', 'foo', 'bar', 'http', 'finished', 'test', 0)
     self.assertEqual(job.job_id, 'test')
     self.assertEqual(job.function, 'foo')
     self.assertEqual(job.context, 'bar')
     self.assertEqual(job.source, 'http')
     self.assertEqual(job.status, 'finished')
     self.assertEqual(job.external_id, 'test')
     self.assertEqual(job.start_time, datetime.datetime.fromtimestamp(0))
コード例 #4
0
    def test_job_to_json(self):
        job = models.Job('test', 'foo', 'bar', 'http', 'finished', 'test', 0)
        res = job.to_json()

        self.assertTrue('jobId' in res)
        self.assertTrue('context' in res)
        self.assertTrue('function' in res)
        self.assertTrue('source' in res)
        self.assertTrue('status' in res)
        self.assertTrue('externalId' in res)
        self.assertTrue('startTime' in res)