#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import pytest
from pyflapjack.jsonapi import FlapjackAPI, Contact, Media
from pyflapjack.jsonapi.errors import NotFoundError, InConsistentError


api = FlapjackAPI(server_url='http://127.0.0.1:13081')
flapjack_available = False
namespace = str(int(time.time()))


def get_id(resource='', oid=''):
    return '_'.join([namespace, resource, oid or str(int(time.time()))])

try:
    api.query(Contact, get_id('contact', '0'))
except NotFoundError:
    flapjack_available = True
except Exception as e:
    pass
require_flapjack = pytest.mark.skipif(
    not flapjack_available, reason='flapjack server not available')


@pytest.fixture
def contact(request):
    contact = Contact(
        id=get_id('contact', 'test'), email='*****@*****.**',
        first_name='1', last_name='2', timezone='Europe/London')
Ejemplo n.º 2
0
def test_delete(api, mock_204):
    api = FlapjackAPI()
    api.delete(Contact, "1")