<commit_before># encoding: utf-8
import httpretty
import pytest
from django.core.urlresolvers import reverse


@pytest.mark.httpretty
def test_get_api_root(client):
    url = reverse('api-root')
    httpretty.register_uri(httpretty.GET, url, content_type='application/json')
    get_response = client.get(url)
    assert get_response.status_code == 200


@pytest.mark.httpretty
@pytest.mark.django_db
def test_list_view_get(client, fixture):
    url = reverse('api-list')
    httpretty.register_uri(httpretty.GET, url,
        body=fixture('base_form.json'), content_type='application/json')
    get_response = client.get(url)
    assert get_response.status_code == 200


@pytest.mark.httpretty
def test_list_view_post(client, form_data):
    url = reverse('api-list')
    httpretty.register_uri(httpretty.POST, url, body=form_data,
        content_type='application/json')
    response = client.post(url, data=form_data, content_type='application/json')
    assert response.status_code == 201<commit_msg>Added detail view test and correct URL building<commit_after># encoding: utf-8
import httpretty
import pytest
from django.core.urlresolvers import reverse


@pytest.mark.httpretty
def test_get_api_root(client):
    url = reverse('api-root')
    httpretty.register_uri(httpretty.GET, url, content_type='application/json')
    get_response = client.get(url)
    assert get_response.status_code == 200


@pytest.mark.httpretty
@pytest.mark.django_db
def test_list_view_get(client, fixture):
    url = reverse('api-list')
    httpretty.register_uri(httpretty.GET, url,
        body=fixture('base_form.json'), content_type='application/json')
    get_response = client.get(url)
    assert get_response.status_code == 200


@pytest.mark.httpretty
def test_list_view_post(client, form_data):
    url = reverse('api-list')
    httpretty.register_uri(httpretty.POST, url, body=form_data,
        content_type='application/json')
    response = client.post(url, data=form_data, content_type='application/json')
    assert response.status_code == 201


@pytest.mark.httpretty
@pytest.mark.django_db
def test_list_view_detail(client, fixture, model):
    url = reverse('api-detail', kwargs={'pk': model.id})
    httpretty.register_uri(httpretty.GET, url,
        body=fixture('base_form.json'), content_type='application/json')
    response = client.get(url)
    assert response.status_code == 200
    assert response.data['url'].startswith('http://')
{'fraction_non_alphanumeric': 0.12029459901800327, 'fraction_numerical': 0.009410801963993453, 'mean_word_length': 4.963414634146342, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1272761', 'n_tokens_mistral': 828, 'n_tokens_neox': 813, 'n_words': 141}