Skip to content

Instantly share code, notes, and snippets.

@pinge
Last active February 15, 2016 15:20
Show Gist options
  • Select an option

  • Save pinge/cbb52aad7eb1441bfd7b to your computer and use it in GitHub Desktop.

Select an option

Save pinge/cbb52aad7eb1441bfd7b to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import pytest
from validation import *
from fixtures import *
CASES = [
{
'TEST CASE': '/accounts should return a 200 OK with the account details',
'fixtures': [
lambda: fixtures.create_account(username='fixture1', email='fixture1@jwplayer.com', password='devdevdev'),
lambda: fixtures.create_account(username='fixture2', email='fixture2@jwplayer.com', password='devdevdev')
],
'method': 'GET',
'path': '/accounts/{:fixture.id}',
'headers': {
'Content-Type': 'application/json'
},
'validation': [
(validate_status_code, 200),
(validate_presence_of, {
'id': '{:fixture.id}',
'username': "{:fixture.username}",
'email': "{:fixture.email}",
'videos': lambda videos: len(videos) == 0
}),
(validate_presence_of_headers, {
'Content-Type': 'application/json; charset=utf-8'
})
]
}
]
@pytest.mark.parametrize('test_case', CASES)
def test_accounts_resource(functional_test, test_case):
"""
Test /accounts endpoint
"""
functional_test.add(test_case)
for Fixture in functional_test.fixtures:
fixture = Fixture()
responses = functional_test.map_requests(test_case['method'], test_case['path'], test_case['headers'],
test_case['payload'], fixture)
for response in responses:
functional_test.validate(response, fixture)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment