示例#1
0
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
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
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
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
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
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
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
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
def get_default_prefs(context):
    response_data = json.loads(context.response.get_data())
    assert_equal(response_data['user_preferences'], default_user_preferences)
示例#14
0
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
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
def get_default_prefs(context):
    response_data = json.loads(context.response.get_data())
    assert_equal(response_data['preferences'], available_preferences)
示例#17
0
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