コード例 #1
0
ファイル: steps.py プロジェクト: rolpro/superdesk-server
def we_mention_user_in_comment(context, url):
    with context.app.mail.record_messages() as outbox:
        step_impl_when_post_url(context, url)
        assert len(outbox) == 1
        assert_equal(outbox[0].subject, "You were mentioned in a comment by test_user")
        email_text = outbox[0].body
        assert email_text
コード例 #2
0
ファイル: steps.py プロジェクト: plaindocs/superdesk-server
def get_desk_spike_expiry(context, test_minutes):
    response_data = json.loads(context.response.get_data())
    assert response_data['expiry']
    response_expiry = datetime.strptime(response_data['expiry'], "%Y-%m-%dT%H:%M:%S+0000")
    expiry = utc.utcnow() + timedelta(minutes=int(test_minutes))
    assert_equal(response_expiry.hour, expiry.hour)
    assert_equal(response_expiry.minute, expiry.minute)
コード例 #3
0
ファイル: steps.py プロジェクト: vied12/superdesk-server
def get_desk_spike_expiry(context, test_minutes):
    response_data = json.loads(context.response.get_data())
    assert response_data['expiry']
    response_expiry = datetime.strptime(response_data['expiry'], "%Y-%m-%dT%H:%M:%S+0000")
    expiry = utc.utcnow() + timedelta(minutes=int(test_minutes))
    assert_equal(response_expiry.hour, expiry.hour)
    assert_equal(response_expiry.minute, expiry.minute)
コード例 #4
0
ファイル: steps.py プロジェクト: plaindocs/superdesk-server
def we_mention_user_in_comment(context, url):
    with context.app.mail.record_messages() as outbox:
        step_impl_when_post_url(context, url)
        assert len(outbox) == 1
        assert_equal(outbox[0].subject, "You were mentioned in a comment by test_user")
        email_text = outbox[0].body
        assert email_text
コード例 #5
0
ファイル: steps.py プロジェクト: vied12/superdesk-server
def test_json(context):
    try:
        response_data = json.loads(context.response.get_data())
    except Exception:
        fail_and_print_body(context.response, 'response is not valid json')
    context_data = json.loads(apply_placeholders(context, context.text))
    assert_equal(json_match(context_data, response_data), True,
                 msg=str(context_data) + '\n != \n' + str(response_data))
コード例 #6
0
def then_we_pushed_x_items(context, count):
    history = context.http_mock.request_history
    assert count == len(history), 'there were %d calls' % (len(history), )
    if context.text:
        context_data = json.loads(apply_placeholders(context, context.text))
        for i, _ in enumerate(context_data):
            assert_equal(json_match(context_data[i], history[i].json()), True,
                         msg='item[%d]: %s' % (i, history[i]))
コード例 #7
0
def test_json(context):
    try:
        response_data = json.loads(context.response.get_data())
    except Exception:
        fail_and_print_body(context.response, 'response is not valid json')
    context_data = json.loads(apply_placeholders(context, context.text))
    assert_equal(json_match(context_data, response_data), True,
                 msg=str(context_data) + '\n != \n' + str(response_data))
コード例 #8
0
ファイル: steps.py プロジェクト: nistormihai/superdesk-server
def then_we_get_notifications(context):
    notifications = context.app.notification_client.messages
    notifications_data = [
        json.loads(notification) for notification in notifications
    ]
    context_data = json.loads(apply_placeholders(context, context.text))
    assert_equal(json_match(context_data, notifications_data),
                 True,
                 msg=str(context_data) + '\n != \n' + str(notifications_data))
コード例 #9
0
def then_we_get_formatted_item(context):
    assert_200(context.response)
    try:
        response_data = json.loads(context.response.get_data())
        formatted_item = json.loads(response_data.get('formatted_item', ''))
    except Exception:
        fail_and_print_body(context.response, 'response does not contain a valid formatted_item field')
    context_data = json.loads(apply_placeholders(context, context.text))
    assert_equal(json_match(context_data, formatted_item), True,
                 msg=str(context_data) + '\n != \n' + str(formatted_item))
コード例 #10
0
def then_we_get_array_of_by(context, field, fid):
    response = get_json_data(context.response)
    assert field in response, '{} field not defined'.format(field)
    assert len(response.get(field)), '{} field not defined'.format(field)
    context_data = json.loads(apply_placeholders(context, context.text))

    for row in response[field]:
        if row[fid] not in context_data.keys():
            continue

        assert_equal(json_match(context_data[row[fid]], row),
                     True,
                     msg=str(row) + '\n != \n' + str(context_data[row[fid]]))
コード例 #11
0
ファイル: steps.py プロジェクト: nistormihai/superdesk-server
def then_we_get_notifications(context):
    notifications = context.app.notification_client.messages
    notifications_data = [json.loads(notification) for notification in notifications]
    context_data = json.loads(apply_placeholders(context, context.text))
    assert_equal(json_match(context_data, notifications_data), True,
                 msg=str(context_data) + '\n != \n' + str(notifications_data))
コード例 #12
0
ファイル: steps.py プロジェクト: vied12/superdesk-server
def get_unspiked_content(context, id):
    url = 'archive/{0}'.format(id)
    when_we_get_url(context, url)
    assert_200(context.response)
    response_data = json.loads(context.response.get_data())
    assert_equal(response_data['state'], 'draft')
コード例 #13
0
ファイル: steps.py プロジェクト: auliakausar/superdesk-server
def get_default_prefs(context):
    response_data = json.loads(context.response.get_data())
    assert_equal(response_data['user_preferences'], default_user_preferences)
コード例 #14
0
ファイル: steps.py プロジェクト: rolpro/superdesk-server
def we_change_user_status(context, status, url):
    with context.app.mail.record_messages() as outbox:
        step_impl_when_patch_url(context, url)
        assert len(outbox) == 1
        assert_equal(outbox[0].subject, "Your Superdesk account is " + status)
        assert outbox[0].body
コード例 #15
0
ファイル: steps.py プロジェクト: auliakausar/superdesk-server
def get_unspiked_content(context, id):
    url = 'archive/{0}'.format(id)
    when_we_get_url(context, url)
    assert_200(context.response)
    response_data = json.loads(context.response.get_data())
    assert_equal(response_data['is_spiked'], None)
コード例 #16
0
ファイル: steps.py プロジェクト: rolpro/superdesk-server
def get_default_prefs(context):
    response_data = json.loads(context.response.get_data())
    assert_equal(response_data['preferences'], available_preferences)
コード例 #17
0
ファイル: steps.py プロジェクト: auliakausar/superdesk-server
def we_change_user_status(context, status, url):
    with context.app.mail.record_messages() as outbox:
        step_impl_when_patch_url(context, url)
        assert len(outbox) == 1
        assert_equal(outbox[0].subject, "Your Superdesk account is " + status)
        assert outbox[0].body