本文整理汇总了Python中okcupyd.User类的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_log_path_for_user_question_not_found
def test_log_path_for_user_question_not_found(mock_time):
mock_time.time.return_value = 2
user = User(mock.Mock())
with mock.patch('okcupyd.profile.Profile.find_question',
return_value=None):
user.get_user_question(mock.Mock())
assert mock_time.sleep.call_count
示例2: test_photo_delete
def test_photo_delete():
user = User()
response_dict = user.photo.upload_and_confirm(user.quickmatch().photo_infos[0])
before_delete_photos = user.profile.photo_infos
user.photo.delete(response_dict['id'])
user.profile.refresh()
assert len(before_delete_photos) - 1 == len(user.profile.photo_infos)
示例3: test_user_essay_refresh
def test_user_essay_refresh():
# Test Refresh Function
user = User()
user2 = User(user._session)
user.message_me_if = 'other stuff'
user2.profile.essays.refresh()
assert user.profile.essays.message_me_if == user2.profile.essays.message_me_if
示例4: test_handle_no_fluency_lanaguages
def test_handle_no_fluency_lanaguages(vcr_live_sleep):
details = User().profile.details
details.languages = [('english', None)]
vcr_live_sleep(sleep_time)
assert details.languages == [('English', None)]
details.languages = [('spanish', None)]
vcr_live_sleep(sleep_time)
assert details.languages == [('Spanish', None)]
示例5: test_user_get_user_question
def test_user_get_user_question():
user = User()
profile = user.quickmatch()
question = profile.questions[0]
user_question = user.get_user_question(question)
assert question.id == user_question.id
assert question.text == user_question.text
assert 0 < user_question.answer_id < 5
assert 0 < user_question.get_answer_id_for_question(question) < 5
示例6: test_question_filter_with_custom_answers
def test_question_filter_with_custom_answers():
user = User()
user_question = user.questions.somewhat_important[1]
unacceptable_answers = [answer_option.id
for answer_option in user_question.answer_options
if not answer_option.is_match]
for profile in user.search(question=user_question.id,
question_answers=unacceptable_answers)[:5]:
question = profile.find_question(user_question.id)
assert not question.their_answer_matches
示例7: test_search_populates_upfront
def test_search_populates_upfront():
user = User()
search_fetchable = user.search()
for profile in search_fetchable[:4]:
profile_session = profile._session
with mock.patch.object(profile, '_session') as mock_session:
mock_session.okc_get.side_effect = profile_session.okc_get
assert profile.id > 0
assert mock_session.okc_get.call_count == 0
profile.essays.self_summary
assert mock_session.okc_get.call_count == 1
示例8: test_load_messages_on_message_thread
def test_load_messages_on_message_thread():
user = User()
content = 'a message was sent'
their_profile = user.quickmatch()
message_info = their_profile.message(content)
while message_info.message_id is None:
their_profile = user.quickmatch()
message_info = their_profile.message(content)
assert len(user.outbox[0].messages) == 1
assert user.outbox[0].messages[0].content == content
示例9: test_pets_detail
def test_pets_detail(vcr_live_sleep):
details = User().profile.details
for relationship in ('has', 'likes', 'dislikes'):
for pet in ('cats', 'dogs'):
details.pets = '{0} {1}'.format(relationship, pet)
vcr_live_sleep(sleep_time)
assert relationship in details.pets.lower()
assert pet in details.pets.lower()
vcr_live_sleep(sleep_time)
details.pets = 'has cats likes dogs'
vcr_live_sleep(sleep_time)
assert details.pets.lower() == 'likes dogs and has cats'
示例10: test_monogamous_detail
def test_monogamous_detail(vcr_live_sleep):
details = User().profile.details
details.monogamous = None
assert details.monogamous == None
for fidelity_type in ('non-monogamous', 'monogamous'):
for strictness in ('strictly', 'mostly'):
details.monogamous = '{0} {1}'.format(strictness, fidelity_type)
vcr_live_sleep(sleep_time)
assert strictness in details.monogamous.lower()
assert fidelity_type in details.monogamous.lower()
示例11: test_languages_detail
def test_languages_detail(vcr_live_sleep):
details = User().profile.details
values = [
[('spanish', 'poorly'), ('english', 'fluently')],
[('catalan', 'okay')],
[('esperanto', 'fluently'), ('dutch', 'okay')],
]
for value in values:
details.languages = value
vcr_live_sleep(sleep_time)
assert details.languages == value
vcr_live_sleep(sleep_time)
示例12: test_initiator_and_respondent
def test_initiator_and_respondent():
user = User()
their_profile = user.quickmatch()
message_info = their_profile.message('initiated contact')
while message_info.message_id is None:
their_profile = user.quickmatch()
message_info = their_profile.message('initiated contact')
message_thread = user.outbox[0]
assert message_thread.initiator.username == user.profile.username
assert message_thread.respondent.username == their_profile.username
assert message_thread.correspondent_id == their_profile.id
示例13: test_profile_questions_copy
def test_profile_questions_copy(vcr_live_sleep):
# This could be better...
with mock.patch('okcupyd.profile_copy.time.sleep', vcr_live_sleep):
user = User()
# Find a user that has answered fewer than 50 questions.
# This is going to issue an insane number of requests if we don't do this
profile = get_profile_with_max_questions(
user, max_questions=50
)
user.copy(profile).questions()
for question in profile.questions():
assert question.their_answer == question.my_answer
示例14: test_delete
def test_delete(vcr_live_sleep):
user = User()
their_profile = user.quickmatch()
message_info = their_profile.message('text')
assert message_info.thread_id != None
thread_id = user.outbox[0].id
user.outbox[0].delete()
vcr_live_sleep(2)
user.outbox()
try:
assert user.outbox[0].id != thread_id
except IndexError:
pass
示例15: test_multi_line_messages
def test_multi_line_messages(vcr_live_sleep):
user = User()
messages = [
"""Multi-line message
first
second
third""",
""" leading whitespace
space at the end
space at the beggining
"""]
for message in messages:
user.quickmatch().message(message)
vcr_live_sleep(2)
assert user.outbox()[0].messages[0].content.strip() == message.strip()