예제 #1
0
def test_create_a_gist_with_different_formats(
        create_authorized_gists_client_instance, file_format):
    gist_client = create_authorized_gists_client_instance
    gist_file = GistFile(f'new{file_format}', 'abcd')

    result = gist_client.gists_action.create_a_gist(gist_file)

    assert result.status_code == 201, result.content
    assert result.content.files[0].filename == gist_file.get_file_name()
예제 #2
0
def test_create_a_gist_with_same_filename(
        create_authorized_gists_client_instance):
    gist_client = create_authorized_gists_client_instance
    gist_file = GistFile('new.txt', 'abcd')
    gist_client.gists_action.create_a_gist(gist_file)
    result = gist_client.gists_action.create_a_gist(gist_file)

    assert result.status_code == 201
    assert result.content.files[0].filename == gist_file.get_file_name()
예제 #3
0
def test_create_a_gist_with_empty_filename_will_generate_name(
        create_authorized_gists_client_instance):
    gist_client = create_authorized_gists_client_instance
    gist_file = GistFile('', 'abcd')
    result = gist_client.gists_action.create_a_gist(gist_file)
    assert result.status_code == 201
    assert result.content.files[0].filename != gist_file
예제 #4
0
def test_create_a_gist(create_authorized_gists_client_instance):
    gist_client = create_authorized_gists_client_instance
    result = gist_client.gists_action.create_a_gist(
        GistFile('abcd.txt', 'abcd'))

    assert result.status_code == 201
    assert result.content.files[0].filename == 'abcd.txt'

    assert result.content.id in get_all_user_gist_ids(gist_client)
예제 #5
0
def test_create_a_gist_without_specify_files_will_throw_error(
        create_authorized_gists_client_instance):
    gist_client = create_authorized_gists_client_instance
    gist_file = GistFile('new.txt', 'abcd')
    gist_client.gists_action.create_a_gist(gist_file)
    result = gist_client.gists_action.create_a_gist(file=None)

    assert result.status_code == 422
    assert 'Invalid request' in result.error.message
예제 #6
0
def test_edit_gist_files(create_gist_with_deletion):
    gist_client, gist = create_gist_with_deletion
    last_file = gist.files[0].filename
    result = gist_client.gists_action.edit_a_gist_by_gist_id(gist.id,
                                                             files=GistFile(
                                                                 'new.txt',
                                                                 'edit txt'))
    assert result.status_code == 200
    file_names = {file.filename for file in result.content.files}
    assert file_names == {'new.txt', last_file}
예제 #7
0
def create_gist_with_deletion(create_authorized_gists_client_instance, request):
    gist_file_example = GistFile(file_name='test.txt', content='abcdefg')
    client = create_authorized_gists_client_instance
    result = client.gists_action.create_a_gist(gist_file_example)

    def clean_gist():
        client.gists_action.delete_a_gist_by_gist_id(result.content.id)

    request.addfinalizer(clean_gist)

    return client, result.content
예제 #8
0
def create_gist(create_authorized_gists_client_instance):
    gist_file_example = GistFile(file_name='test.txt', content='abcdefg')
    client = create_authorized_gists_client_instance
    result = client.gists_action.create_a_gist(gist_file_example)

    return client, result.content