Ejemplo n.º 1
0
def test_request_find():
    r = RequestReference(host=TESTING_CONFIG['host'],
                        port=TESTING_CONFIG['port'])
    req_dict = dict(sample='hidefix', time=time.time(),
                    uid=str(uuid4()), state='active', seq_num=0, foo='bar',
                    hero='obelix', antihero='romans')
    inserted = r.create(**req_dict)
    retrieved = next(r.find(foo='bar'))
    assert retrieved['uid'] == inserted
Ejemplo n.º 2
0
def test_request_find():
    r = RequestReference(host=TESTING_CONFIG['host'],
                        port=TESTING_CONFIG['port'])
    req_dict = dict(sample='hidefix', time=time.time(),
                    uid=str(uuid4()), state='active', seq_num=0, foo='bar',
                    hero='obelix', antihero='romans')
    inserted = r.create(**req_dict)
    retrieved = next(r.find(foo='bar'))
    assert retrieved['uid'] == inserted
Ejemplo n.º 3
0
def test_request_create():
    req1= RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])

    req2 = RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])
    req2.create(sample='roman_sample', time=time.time(),
               uid=None, state='active', seq_num=0, foo='bar',
               hero='asterix', antihero='romans')
Ejemplo n.º 4
0
def test_request_create():
    req1= RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])

    req2 = RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])
    req2.create(sample='roman_sample', time=time.time(),
               uid=None, state='active', seq_num=0, foo='bar',
               hero='asterix', antihero='romans')
    req2.host = 'hail_caesar'
    pytest.raises(ConnectionError, req2.create, sample='roman_sample')
Ejemplo n.º 5
0
def test_duplicate_request():
    m_uid = str(uuid4())
    req1= RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])
    req1.create(sample='hidefix', time=time.time(),
               uid=m_uid, state='active', seq_num=0, foo='bar',
               hero='asterix', antihero='romans')
    req2 = RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])
    pytest.raises(HTTPError, req2.create, sample='hidefix', time=time.time(),
               uid=m_uid, state='active', seq_num=0, foo='bar',
               hero='asterix', antihero='romans')
Ejemplo n.º 6
0
def test_duplicate_request():
    m_uid = str(uuid4())
    req1= RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])
    req1.create(sample='hidefix', time=time.time(),
               uid=m_uid, state='active', seq_num=0, foo='bar',
               hero='asterix', antihero='romans')
    req2 = RequestReference(host=TESTING_CONFIG['host'],
                           port=TESTING_CONFIG['port'])
    pytest.raises(HTTPError, req2.create, sample='hidefix', time=time.time(),
               uid=m_uid, state='active', seq_num=0, foo='bar',
               hero='asterix', antihero='romans')
Ejemplo n.º 7
0
def test_update_request():
    r = RequestReference(host=TESTING_CONFIG['host'],
                        port=TESTING_CONFIG['port'])
    m_uid = str(uuid4())
    req_dict = dict(sample='hidefix', time=time.time(),
                    uid=m_uid, state='active', seq_num=0, foo='bar',
                    hero='obelix', antihero='romans')
    r.create(**req_dict)
    r.update(query={'uid': m_uid},
                       update={'state': 'inactive'})
    updated_req = next(r.find(uid=m_uid))
    assert updated_req['state'] == 'inactive'
Ejemplo n.º 8
0
def test_update_request():
    r = RequestReference(host=TESTING_CONFIG['host'],
                        port=TESTING_CONFIG['port'])
    m_uid = str(uuid4())
    req_dict = dict(sample='hidefix', time=time.time(),
                    uid=m_uid, state='active', seq_num=0, foo='bar',
                    hero='obelix', antihero='romans')
    r.create(**req_dict)
    r.update(query={'uid': m_uid},
                       update={'state': 'inactive'})
    updated_req = next(r.find(uid=m_uid))
    assert updated_req['state'] == 'inactive'
Ejemplo n.º 9
0
def test_request_create():
    req1 = RequestReference(host=TESTING_CONFIG['host'],
                            port=TESTING_CONFIG['port'])

    req2 = RequestReference(host=TESTING_CONFIG['host'],
                            port=TESTING_CONFIG['port'])
    req2.create(sample='roman_sample',
                time=time.time(),
                uid=None,
                state='active',
                seq_num=0,
                foo='bar',
                hero='asterix',
                antihero='romans')
    req2.host = 'hail_caesar'
    pytest.raises(ConnectionError, req2.create, sample='roman_sample')
Ejemplo n.º 10
0
def test_req_connection_switch():
    r = RequestReference()
    r.host = 'bogus_paigh'
    pytest.raises(ConnectionError, r.create, 'test')
    r.host = 'localhost'
    list(r.find())
Ejemplo n.º 11
0
def test_request_constructor_config():
    r1 = RequestReference(host=TESTING_CONFIG['host'],
                          port=TESTING_CONFIG['port'])
    assert r1.host == TESTING_CONFIG['host']
    assert r1.port == TESTING_CONFIG['port']
Ejemplo n.º 12
0
def test_req_connection_switch():
    r = RequestReference()
    r.host = 'bogus_paigh'
    pytest.raises(ConnectionError, r.create, 'test')
    r.host = 'localhost'
    list(r.find())