def test_file_store_basic_mapping(tmppath):
    store = FileStore(tmppath)
    assert not list(store)
    assert not len(store)
    store[1] = {}
    assert list(store) == ['1']
    assert len(store) == 1
    assert store[1] == {}

    assert store.raw_data(1) == b'{}'

    assert 1 in store

    del store[1]
    with pytest.raises(KeyError):
        store[1]

    assert 1 not in store
def convert(store):
    issues, comments = bitbucket.stores(store)

    simple_store = FileStore.ensure(store.path / 'github_uploads')

    repo = store['repos']['bitbucket']
    items = issues.items()
    for key, issue in gprocess(items, label='Preparing Import Requests'):
        issue['comments'] = comments[key]
        simplified = bitbucket.simplify_issue(
                bb_issue=issue,
                repo=repo,
                usermap=store.get('users', {}))
        simple_store[key] = simplified
def convert(store, usermap=None):
    issues, comments = bitbucket.stores(store)

    simple_store = FileStore.ensure(store.path / 'github_uploads')

    repo = store['repos']['bitbucket']
    items = issues.items()
    usermap = usermap or store.get('users', {})
    for key, issue in gprocess(items, label='Preparing Import Requests'):
        issue['comments'] = comments[key]
        simplified = bitbucket.simplify_issue(bb_issue=issue,
                                              repo=repo,
                                              usermap=usermap)
        simple_store[key] = simplified
def upload_github_issues(store, token):
    from wait_for import wait_for
    post = get_github_issue_poster(store, token)
    simple_store = FileStore.ensure(store.path / 'github_uploads')
    for issue in gprocess(sorted(simple_store, key=int),
                          label='Uploading Import Requests'):
        response = post.get_issue(issue)
        if response.status_code == 200:
            raise ValueError(issue)
        post(simple_store.raw_data(issue))

        def failure_check(response):
            print(repr(response.status_code), response.url)
            return response.status_code != 200

        wait_for(post.get_issue, (issue, ),
                 fail_condition=failure_check,
                 timeout=500)
def upload_github_issues(store, token):
    from wait_for import wait_for
    post = get_github_issue_poster(store, token)
    simple_store = FileStore.ensure(store.path / 'github_uploads')
    for issue in gprocess(sorted(simple_store, key=int),
                          label='Uploading Import Requests'):
        response = post.get_issue(issue)
        if response.status_code == 200:
            raise ValueError(issue)
        post(simple_store.raw_data(issue))

        def failure_check(response):
            print(repr(response.status_code), response.url)
            return response.status_code != 200
        wait_for(
            post.get_issue, (issue,),
            fail_condition=failure_check,
            timeout=500)
def test_file_store_creation(tmppath):
    new = tmppath / 'test'

    FileStore.open(tmppath)

    with pytest.raises(NotADirectoryError):
        FileStore.open(new)

    with pytest.raises(FileExistsError):
        FileStore.create(tmppath)

    FileStore.create(new)
    FileStore.open(new)

    FileStore.ensure(tmppath / 'test2' / '2')
    FileStore.ensure(tmppath / 'test2')
def init(*, path, bitbucket, github):
    store = FileStore.ensure(path)
    store['repos'] = {'bitbucket': bitbucket, 'github': github}
def init(*, path, bitbucket, github):
    store = FileStore.ensure(path)
    store['repos'] = {
        'bitbucket': bitbucket,
        'github': github
    }
def upload_github_issues(store, token):
    post = get_github_issue_poster(store, token)
    simple_store = FileStore.ensure(store.path / 'github_uploads')
    for issue in gprocess(simple_store, label='Uploading Import Requests'):
        post(simple_store.raw_data(issue))
Example #10
0
def main(ctx, target):
    ctx.obj = FileStore(path=target)