コード例 #1
0
ファイル: packs.py プロジェクト: bossjones/ultron8
def create_random_packs(db: Session) -> Packs:
    shared_name = random_lower_string()
    name = shared_name
    description = random_lower_string()
    keywords = random_lower_string()
    version = random_lower_string()
    python_versions = random_lower_string()
    author = random_lower_string()
    email = "*****@*****.**"
    # contributors = [random_lower_string()]
    # files = [random_lower_string()]
    contributors = random_lower_string()
    files = random_lower_string()
    path = random_lower_string()
    ref = shared_name

    packs_in = PacksCreate(
        name=name,
        description=description,
        keywords=keywords,
        version=version,
        python_versions=python_versions,
        author=author,
        email=email,
        contributors=contributors,
        files=files,
        path=path,
        ref=ref,
    )

    packs = crud.packs.create(db_session=db, packs_in=packs_in)
    return packs
コード例 #2
0
ファイル: test_packs.py プロジェクト: bossjones/ultron8
def test_get_packs(db: Session) -> None:
    name = random_lower_string()
    description = random_lower_string()
    keywords = random_lower_string()
    version = random_lower_string()
    python_versions = random_lower_string()
    author = random_lower_string()
    email = "*****@*****.**"
    contributors = random_lower_string()
    files = random_lower_string()
    path = random_lower_string()
    ref = random_lower_string()

    packs_in = PacksCreate(
        name=name,
        description=description,
        keywords=keywords,
        version=version,
        python_versions=python_versions,
        author=author,
        email=email,
        contributors=contributors,
        files=files,
        path=path,
        ref=ref,
    )
    packs = crud.packs.create(db, packs_in=packs_in)
    packs_2 = crud.packs.get(db, packs_id=packs.id)
    assert jsonable_encoder(packs) == jsonable_encoder(packs_2)
コード例 #3
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
コード例 #4
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
コード例 #5
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)
コード例 #6
0
ファイル: test_packs.py プロジェクト: bossjones/ultron8
def test_delete_packs(db: Session) -> None:
    name = random_lower_string()
    description = random_lower_string()
    keywords = random_lower_string()
    version = random_lower_string()
    python_versions = random_lower_string()
    author = random_lower_string()
    email = "*****@*****.**"
    contributors = random_lower_string()
    files = random_lower_string()
    path = random_lower_string()
    ref = random_lower_string()

    packs_in = PacksCreate(
        name=name,
        description=description,
        keywords=keywords,
        version=version,
        python_versions=python_versions,
        author=author,
        email=email,
        contributors=contributors,
        files=files,
        path=path,
        ref=ref,
    )
    packs = crud.packs.create(db, packs_in=packs_in)

    packs2 = crud.packs.remove(db_session=db, id=packs.id)

    packs3 = crud.packs.get(db_session=db, packs_id=packs.id)

    assert packs3 is None

    assert packs2.id == packs.id
    assert packs2.name == name
    assert packs2.description == description
    assert packs2.keywords == keywords
    assert packs2.version == version
    assert packs2.python_versions == python_versions
    assert packs2.author == author
    assert packs2.email == email
    assert packs2.contributors == contributors
    assert packs2.files == files
    assert packs2.path == path
    assert packs2.ref == ref
    assert packs2.created_at == "2019-07-25 01:11:00.740428"
    assert packs2.updated_at == "2019-07-25 01:11:00.740428"
コード例 #7
0
ファイル: test_packs.py プロジェクト: bossjones/ultron8
def test_create_packs(db: Session) -> None:
    name = "linuxtest"
    description = "TEST Generic Linux actions"
    keywords = "linux"
    version = "0.1.0"
    python_versions = "3"
    author = "Jarvis"
    email = "*****@*****.**"
    contributors = "bossjones"
    files = "./tests/fixtures/simple/packs/linux"
    path = "./tests/fixtures/simple/packs/linux"
    ref = "linux"

    packs_in = PacksCreate(
        name=name,
        description=description,
        keywords=keywords,
        version=version,
        python_versions=python_versions,
        author=author,
        email=email,
        contributors=contributors,
        files=files,
        path=path,
        ref=ref,
    )
    packs = crud.packs.create(db, packs_in=packs_in)
    assert packs.name == name
    assert packs.description == description
    assert packs.keywords == keywords
    assert packs.version == version
    assert packs.python_versions == python_versions
    assert packs.author == author
    assert packs.email == email
    assert packs.contributors == contributors
    assert packs.files == files
    assert packs.path == path
    assert packs.ref == ref
    assert packs.created_at == "2019-07-25 01:11:00.740428"
    assert packs.updated_at == "2019-07-25 01:11:00.740428"
コード例 #8
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