Пример #1
0
def test_save_flow_ver(fixture_registry_bucket, fixture_pg, fixture_processor):
    test_pg = fixture_pg.generate()
    test_b, test_rc = fixture_registry_bucket
    r1 = versioning.save_flow_ver(process_group=test_pg,
                                  registry_client=test_rc,
                                  bucket=test_b,
                                  flow_name=config.test_versioned_flow_name,
                                  comment='a test comment',
                                  desc='a test description')
    assert isinstance(r1, nifi.VersionControlInformationEntity)
    # Next we validate you can't duplicate a flow name in a bucket
    with pytest.raises(ValueError):
        _ = versioning.save_flow_ver(process_group=test_pg,
                                     registry_client=test_rc,
                                     bucket=test_b,
                                     flow_name=config.test_versioned_flow_name,
                                     comment='NiPyApi Test',
                                     desc='NiPyApi Test')
    # Add a processor, refresh status, and save a new version
    fixture_processor.generate(parent_pg=test_pg)
    test_pg = canvas.get_process_group(test_pg.id, 'id')
    r2 = versioning.save_flow_ver(
        process_group=test_pg,
        registry_client=test_rc,
        bucket=test_b,
        flow_id=r1.version_control_information.flow_id,
        comment='a test comment')
    assert isinstance(r2, nifi.VersionControlInformationEntity)
    assert r2.version_control_information.version > \
           r1.version_control_information.version
Пример #2
0
def test_save_flow_ver(regress_flow_reg, fix_bucket, fix_pg, fix_proc):
    f_reg_client = conftest.ensure_registry_client(
        config.registry_local_name
    )
    f_bucket = fix_bucket()
    f_pg = fix_pg.generate()
    test_bucket = versioning.get_registry_bucket(f_bucket.identifier, 'id')
    assert test_bucket.name == conftest.test_bucket_name
    r1 = versioning.save_flow_ver(
        process_group=f_pg,
        registry_client=f_reg_client,
        bucket=test_bucket,
        flow_name=conftest.test_versioned_flow_name,
        comment='a test comment',
        desc='a test description'
    )
    assert isinstance(r1, nifi.VersionControlInformationEntity)
    # Next we validate you can't duplicate a flow name in a bucket
    with pytest.raises(ValueError):
        _ = versioning.save_flow_ver(
            process_group=f_pg,
            registry_client=f_reg_client,
            bucket=f_bucket,
            flow_name=conftest.test_versioned_flow_name,
            comment='NiPyApi Test',
            desc='NiPyApi Test'
        )
    # Add a processor, refresh status, and save a new version
    fix_proc.generate(parent_pg=f_pg)
    f_pg = canvas.get_process_group(f_pg.id, 'id')
    r2 = versioning.save_flow_ver(
        process_group=f_pg,
        registry_client=f_reg_client,
        bucket=f_bucket,
        flow_id=r1.version_control_information.flow_id,
        comment='a test comment'
    )
    assert isinstance(r2, nifi.VersionControlInformationEntity)
    assert r2.version_control_information.version > \
        r1.version_control_information.version
    with pytest.raises(ValueError):
        _ = versioning.save_flow_ver(
            process_group=f_pg,
            registry_client=f_reg_client,
            bucket=f_bucket,
            flow_name=conftest.test_versioned_flow_name,
            comment='a test comment',
            desc='a test description',
            refresh=False
        )
    # shortcut to clean up the test objects when not using the fixture
    conftest.cleanup_reg()