Пример #1
0
def test_update_item_throws_exception_for_missing_body():
    data = {'body': "Text"}
    response = items.create(data)
    id = response['id']

    with pytest.raises(TransportException) as excinfo:
        items.update(id, {})
    assert 'body' in excinfo.value.message
Пример #2
0
def test_multiple_new_terms_applied_to_item(taxonomy):
    item = items.create({'body': "What is the cuse of ebola?"})

    term_names = ['Monrovia', 'age 40-45', 'pertinent']

    item = items.add_terms(
        item['id'], taxonomy.slug, term_names)

    stored_names = [t['name'] for t in item['terms']]

    assert sorted(term_names) == sorted(stored_names)
Пример #3
0
def test_update_item_updates_item():
    data = {'body': "Text"}
    response = items.create(data)
    id = response['id']

    data['body'] = "Updated text"
    response = items.update(id, data)

    # TODO: Update to use items.get() when ready
    assert len(items.list(body="Text")) == 0

    [updated_item] = items.list(body="Updated text")

    assert updated_item['id'] == id
Пример #4
0
def test_add_terms_raises_transport_exception_if_taxonomy_absent():
    item = items.create({'body': "What is the cuse of ebola?"})

    term_names = ['Monrovia', 'age 40-45', 'pertinent']
    with pytest.raises(TransportException) as excinfo:
        items.add_terms(item['id'], 'unknown-slug', term_names)

    error = excinfo.value.message

    assert error['status_code'] == 400
    assert error['detail'] == "Taxonomy matching query does not exist."
    assert error['item_id'] == item['id']
    assert error['terms']['name'] == term_names
    assert error['terms']['taxonomy'] == 'unknown-slug'
def item_data():
    item = {"body": "What is the cuse of ebola?"}
    return items.create(item)