def test_evaluate_disjoint_dag(self, tmpdir):
        output_path = os.path.join(tmpdir, "steps.json")
        args = parse_args([
            "--evaluate", output_path,
            os.path.join(resources_dir, "disjoint_dag")
        ])
        main(args)
        nodes = json.load(open(output_path))["nodes"]
        assert len(nodes) == 2

        nodes.sort(key=lambda x: x["info"]["name"])
        assert nodes[0]["info"] == {
            "name": "step1",
            "description": "A description",
            "file": os.path.join(resources_dir, "disjoint_dag",
                                 "disjoint_dag.py"),
            "line_range": [11, 14]
        }
        assert nodes[1]["info"] == {
            "name": "step2",
            "description": "Another description",
            "file": os.path.join(resources_dir, "disjoint_dag",
                                 "disjoint_dag.py"),
            "line_range": [16, 19]
        }
 def test_evaluate_bad_dag(self, tmpdir):
     output_path = os.path.join(tmpdir, "steps.json")
     args = parse_args([
         "--evaluate", output_path,
         os.path.join(resources_dir, "bad_dag")
     ])
     with pytest.raises(UserCodeExecutionException):
         main(args)
 def test_evaluate_imports(self, tmpdir):
     output_path = os.path.join(tmpdir, "steps.json")
     args = parse_args([
         "--evaluate", output_path,
         os.path.join(resources_dir, "import_dag")
     ])
     main(args)
     steps = json.load(open(output_path))
     assert len(steps) == 1
    def test_execute_step(self, tmpdir):
        output_path = os.path.join(tmpdir, "steps.json")
        args = parse_args([
            "--evaluate", output_path,
            os.path.join(resources_dir, "good_dag")
        ])
        main(args)

        nodes = json.load(open(output_path))["nodes"]
        args = parse_args([
            "--execute", nodes[0]["id"], "--namespace", "test", "--api-token",
            "my-special-token",
            os.path.join(resources_dir, "good_dag")
        ])
        main(args)