Ejemplo n.º 1
0
    def test_copy_accepts_task_args(self):
        t = Task()
        t2 = t.copy(name="new-task")
        t3 = t.copy(**{"max_retries": 4200})

        assert t2.name == "new-task"
        assert t3.max_retries == 4200
Ejemplo n.º 2
0
    def test_copy_warns_if_dependencies_in_active_flow(self):
        t1 = Task()
        t2 = Task()

        with Flow(name="test"):
            t1.set_dependencies(downstream_tasks=[t2])
            with pytest.warns(UserWarning):
                t1.copy()

            with Flow(name="test"):
                # no dependencies in this flow
                t1.copy()
Ejemplo n.º 3
0
    def test_copy_warns_if_dependencies_in_active_flow(self):
        t1 = Task()
        t2 = Task()

        with Flow(name="test") as flow:
            t1.set_dependencies(downstream_tasks=[t2])
            with pytest.warns(UserWarning, match="You are making a copy"):
                flow.add_task(t1.copy())

        with Flow(name="test") as flow:
            with pytest.warns(None) as rec:
                flow.add_task(t1.copy())
            # no dependencies in this flow
            assert len(rec) == 0
Ejemplo n.º 4
0
def test_copying_then_setting_tags_doesnt_leak_backwards():
    with Flow(name="test"):
        t1 = Task()
        with tasks.tags("init-tag"):
            t2 = t1.copy()

    assert t2.tags == {"init-tag"}
    assert t1.tags == set()
Ejemplo n.º 5
0
 def test_copy_accepts_slug_as_task_args(self):
     t = Task(slug="test")
     t2 = t.copy(slug="test-2")
     assert t.slug == "test"
     assert t2.slug == "test-2"
Ejemplo n.º 6
0
 def test_copy_changes_slug(self):
     t1 = Task(slug="test")
     t2 = t1.copy()
     assert t1.slug == "test"
     assert t1.slug != t2.slug
Ejemplo n.º 7
0
 def test_copy_changes_id(self):
     t1 = Task()
     t2 = t1.copy()
     assert t1.id != t2.id