Example #1
0
def test_delete_trigger_tags(db: Session) -> None:
    packs_shared_name = random_lower_string()
    packs_name = packs_shared_name
    packs_description = random_lower_string()
    packs_keywords = random_lower_string()
    packs_version = random_lower_string()
    packs_python_versions = random_lower_string()
    packs_author = random_lower_string()
    packs_email = "*****@*****.**"
    packs_contributors = random_lower_string()
    packs_files = random_lower_string()
    packs_path = random_lower_string()
    packs_ref = packs_shared_name

    trigger_name = TRIGGER_0["name"]
    trigger_packs_name = packs_name
    trigger_description = TRIGGER_0["description"]
    trigger_type = TRIGGER_0["type"]
    trigger_parameters = TRIGGER_0["parameters"]

    packs_in = PacksCreate(
        name=packs_name,
        description=packs_description,
        keywords=packs_keywords,
        version=packs_version,
        python_versions=packs_python_versions,
        author=packs_author,
        email=packs_email,
        contributors=packs_contributors,
        files=packs_files,
        path=packs_path,
        ref=packs_ref,
    )

    packs = crud.packs.create(db, packs_in=packs_in)

    trigger_in = TriggerCreate(
        name=trigger_name,
        packs_name=trigger_packs_name,
        description=trigger_description,
        type=trigger_type,
        parameters=trigger_parameters,
    )

    trigger = crud.trigger.create(db, trigger_in=trigger_in, packs_id=packs.id)

    trigger2 = crud.trigger.remove(db_session=db, trigger_id=trigger.id)

    trigger3 = crud.trigger.get(db_session=db, trigger_id=trigger.id)

    assert trigger3 is None

    assert trigger2.id == trigger.id
    assert trigger2.name == trigger.name
    assert trigger2.packs_name == trigger.packs_name
    assert trigger2.description == trigger2.description
    assert trigger2.type == trigger.type
    assert trigger2.parameters == trigger.parameters
Example #2
0
def test_update_trigger(db: Session) -> None:
    packs_name = "dummy_pack_1"
    packs_description = random_lower_string()
    packs_keywords = random_lower_string()
    packs_version = random_lower_string()
    packs_python_versions = random_lower_string()
    packs_author = random_lower_string()
    packs_email = "*****@*****.**"
    packs_contributors = random_lower_string()
    packs_files = random_lower_string()
    packs_path = random_lower_string()
    packs_ref = "dummy_pack_1"

    trigger_name = TRIGGER_0["name"]
    trigger_packs_name = packs_name
    trigger_description = TRIGGER_0["description"]
    trigger_type = TRIGGER_0["type"]
    trigger_parameters = TRIGGER_0["parameters"]

    packs_in = PacksCreate(
        name=packs_name,
        description=packs_description,
        keywords=packs_keywords,
        version=packs_version,
        python_versions=packs_python_versions,
        author=packs_author,
        email=packs_email,
        contributors=packs_contributors,
        files=packs_files,
        path=packs_path,
        ref=packs_ref,
    )

    packs = crud.packs.create(db, packs_in=packs_in)

    trigger_in = TriggerCreate(
        name=trigger_name,
        packs_name=trigger_packs_name,
        description=trigger_description,
        type=trigger_type,
        parameters=trigger_parameters,
    )

    trigger = crud.trigger.create(db, trigger_in=trigger_in, packs_id=packs.id)
    description2 = random_lower_string()
    trigger_update = TriggerUpdate(description=description2)
    trigger2 = crud.trigger.update(db_session=db,
                                   trigger=trigger,
                                   trigger_in=trigger_update)

    assert trigger.name == trigger2.name
    assert trigger.packs_name == trigger2.packs_name
    assert trigger.description == description2
    assert trigger.type == trigger2.type
    assert trigger.parameters == trigger2.parameters
Example #3
0
def test_get_by_ref_trigger_tags(db: Session) -> None:
    pack_shared_name = random_lower_string()
    packs_name = pack_shared_name
    packs_description = random_lower_string()
    packs_keywords = random_lower_string()
    packs_version = random_lower_string()
    packs_python_versions = random_lower_string()
    packs_author = random_lower_string()
    packs_email = "*****@*****.**"
    packs_contributors = random_lower_string()
    packs_files = random_lower_string()
    packs_path = random_lower_string()
    packs_ref = pack_shared_name

    trigger_name = TRIGGER_0["name"]
    trigger_packs_name = packs_name
    trigger_description = TRIGGER_0["description"]
    trigger_type = TRIGGER_0["type"]
    trigger_parameters = TRIGGER_0["parameters"]

    packs_in = PacksCreate(
        name=packs_name,
        description=packs_description,
        keywords=packs_keywords,
        version=packs_version,
        python_versions=packs_python_versions,
        author=packs_author,
        email=packs_email,
        contributors=packs_contributors,
        files=packs_files,
        path=packs_path,
        ref=packs_ref,
    )

    packs = crud.packs.create(db, packs_in=packs_in)

    trigger_in = TriggerCreate(
        name=trigger_name,
        packs_name=trigger_packs_name,
        description=trigger_description,
        type=trigger_type,
        parameters=trigger_parameters,
    )

    trigger = crud.trigger.create(db, trigger_in=trigger_in, packs_id=packs.id)
    ref_lookup = "{}.{}".format(packs_name, trigger.name)
    trigger_2 = crud.trigger.get_by_ref(db, ref=ref_lookup)
    assert jsonable_encoder(trigger) == jsonable_encoder(trigger_2)
Example #4
0
def test_get_multi_by_packs_id_trigger_tags(db: Session) -> None:
    pack_shared_name = random_lower_string()
    packs_name = pack_shared_name
    packs_description = random_lower_string()
    packs_keywords = random_lower_string()
    packs_version = random_lower_string()
    packs_python_versions = random_lower_string()
    packs_author = random_lower_string()
    packs_email = "*****@*****.**"
    packs_contributors = random_lower_string()
    packs_files = random_lower_string()
    packs_path = random_lower_string()
    packs_ref = pack_shared_name

    trigger_name0 = random_lower_string()
    trigger_packs_name0 = packs_name
    trigger_description0 = TRIGGER_0["description"]
    trigger_type0 = TRIGGER_0["type"]
    trigger_parameters0 = TRIGGER_0["parameters"]

    trigger_name1 = random_lower_string()
    trigger_packs_name1 = packs_name
    trigger_description1 = TRIGGER_1["description"]
    trigger_type1 = TRIGGER_1["type"]
    trigger_parameters1 = TRIGGER_1["parameters"]

    packs_in = PacksCreate(
        name=packs_name,
        description=packs_description,
        keywords=packs_keywords,
        version=packs_version,
        python_versions=packs_python_versions,
        author=packs_author,
        email=packs_email,
        contributors=packs_contributors,
        files=packs_files,
        path=packs_path,
        ref=packs_ref,
    )

    packs = crud.packs.create(db, packs_in=packs_in)

    trigger_in0 = TriggerCreate(
        name=trigger_name0,
        packs_name=trigger_packs_name0,
        description=trigger_description0,
        type=trigger_type0,
        parameters=trigger_parameters0,
    )

    trigger_in1 = TriggerCreate(
        name=trigger_name1,
        packs_name=trigger_packs_name1,
        description=trigger_description1,
        type=trigger_type1,
        parameters=trigger_parameters1,
    )

    trigger0 = crud.trigger.create(db,
                                   trigger_in=trigger_in0,
                                   packs_id=packs.id)
    trigger1 = crud.trigger.create(db,
                                   trigger_in=trigger_in1,
                                   packs_id=packs.id)

    trigger_2 = crud.trigger.get_multi_by_packs_id(db,
                                                   packs_id=packs.id,
                                                   limit=2)

    for t in trigger_2:
        assert type(t) == TriggerDB
        assert t.packs_id == packs.id