Пример #1
0
def test_get_500(monkeypatch):
    def mock_repo_get(params={}, headers={}):
        return MockResponse(None, 500)

    monkeypatch.setattr(zkrq_repository, 'get', mock_repo_get)

    with pytest.raises(Exception):
        unit.get()
Пример #2
0
def test_get_params_object(monkeypatch):
    def mock_repo_get(params={}, headers={}):
        assert 'queueID' in params
        assert 'ttw' in params
        assert 'a' == params['queueID']
        assert 9 == params['ttw']

        return MockResponse({'package': {'unit': 'test', 'killID': 1}}, 200)

    monkeypatch.setattr(zkrq_repository, 'get', mock_repo_get)

    unit.get('a', 9)
Пример #3
0
def processing_loop():
    logger.debug('Processing loop tick')
    kill = zkrq_service.get(ZKRQ_QUEUE_ID, ZKRQ_TTW)
    if kill:
        labels = processing.process(kill)
        for label in labels:
            tracked_kill_service.add(label, kill)
Пример #4
0
def test_get_200_with_no_body(monkeypatch):
    def mock_repo_get(params={}, headers={}):
        return MockResponse({'package': None}, 200)

    monkeypatch.setattr(zkrq_repository, 'get', mock_repo_get)

    response = unit.get()
    assert response is None
Пример #5
0
def test_get_header_object(monkeypatch):
    def mock_getenv(*args, **kwargs):
        return 'mock user agent'

    def mock_repo_get(params={}, headers={}):
        assert 'queueID' in params
        assert 'ttw' in params
        assert 'a' == params['queueID']
        assert 9 == params['ttw']
        assert 'User-Agent' in headers
        assert 'mock user agent' == headers['User-Agent']

        return MockResponse({'package': {'unit': 'test', 'killID': 1}}, 200)

    monkeypatch.setattr(os, 'getenv', mock_getenv)
    monkeypatch.setattr(zkrq_repository, 'get', mock_repo_get)

    unit.get('a', 9)
Пример #6
0
def test_get_200_with_body(monkeypatch):
    def mock_repo_get(params={}, headers={}):
        return MockResponse({'package': {'unit': 'test', 'killID': 1}}, 200)

    monkeypatch.setattr(zkrq_repository, 'get', mock_repo_get)

    response = unit.get()
    assert 'package' in response
    assert 'unit' in response['package']
    assert 'test' == response['package']['unit']