Exemplo n.º 1
0
def test_update(client):
    site = SiteFactory.create()
    data = {
        'id': site.id,
        'url': 'http://example.com',
    }
    response = client.patch('/sites/%s' % site.id, data=data)
    assert_response(response, 200, {'id': site.id, 'url': 'http://example.com'})
Exemplo n.º 2
0
def test_list(client):
    site = SiteFactory.create()
    count = 10
    users = UserFactory.create_batch(count, site=site)
    response = client.get('/users/')
    assert_response(response, 200, [{
        'id': user.id,
        'url': user.url
    } for user in users])
Exemplo n.º 3
0
def test_create(client):
    site = SiteFactory.create()
    data = {
        'site_id': site.id,
        'username': '******',
        'email': '*****@*****.**',
        'url': 'https://joesoap.example.com/'
    }
    response = client.post('/users/', data=data)
    assert_response(response, 201, data)
Exemplo n.º 4
0
def test_list(client):
    count = 10
    sites = SiteFactory.create_batch(count)
    response = client.get('/sites/')
    assert_response(response, 200, [{'id': site.id, 'url': site.url, 'origins': None} for site in sites])
Exemplo n.º 5
0
def test_retrieve(client):
    site = SiteFactory.create()
    response = client.get('/sites/%s' % site.id)
    assert_response(response, 200, {'id': site.id, 'url': site.url, 'origins': None})
Exemplo n.º 6
0
def test_create_with_origins(client):
    data = vars(SiteFactory.stub(origins=['http://example.com', 'https://example.com']))
    response = client.post('/sites/', data=data)
    assert_response(response, 201, data)
Exemplo n.º 7
0
def test_create(client):
    data = vars(SiteFactory.stub())
    response = client.post('/sites/', data=data)
    assert_response(response, 201, data)
Exemplo n.º 8
0
import random

from comments import app
from comments.factories import SiteFactory, UserFactory, TopicFactory, CommentFactory
from comments.models import db

with app.app_context():
    db.create_all()

    for site in SiteFactory.create_batch(3):
        topics = TopicFactory.create_batch(random.randint(3, 10), site=site)
        for user in UserFactory.create_batch(random.randint(1, 10), site=site):
            for topic in topics:
                CommentFactory.create_batch(random.randint(0, 5), topic=topic, user=user)