本文整理汇总了Python中myjobs.tests.factories.UserFactory.delete方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.delete方法的具体用法?Python UserFactory.delete怎么用?Python UserFactory.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myjobs.tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SavedSearchDeletionTests
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import delete [as 别名]
class SavedSearchDeletionTests(MyJobsBase):
# Creating an entire test class for this is kind of overkill but it doesn't
# fit with any of the others.
def setUp(self):
super(SavedSearchDeletionTests, self).setUp()
self.user = UserFactory()
self.creator = UserFactory(email='[email protected]')
self.search = SavedSearchFactory(user=self.user)
self.partner_search = PartnerSavedSearchFactory(user=self.user,
created_by=self.creator)
def test_deletion_and_preservation(self):
"""
When a user is deleted, that user's saved searches should be deleted.
Partner saved searches should be left alone with the exception of
nullifying the recipient.
"""
mail.outbox = []
self.assertEqual(MessageInfo.objects.count(), 0)
self.user.delete()
with self.assertRaises(SavedSearch.DoesNotExist):
SavedSearch.objects.get(pk=self.search.pk)
SavedSearch.objects.get(pk=self.partner_search.pk)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(MessageInfo.objects.count(), 1)
示例2: test_bad_events_deactivate_user
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import delete [as 别名]
def test_bad_events_deactivate_user(self):
now = datetime.datetime.now()
for event in STOP_SENDING + BAD_EMAIL:
u = UserFactory(email="[email protected]",
is_verified=True, opt_in_myjobs=True)
self.make_email_logs(u.email, event, now, False, 3)
process_batch_events()
u = User.objects.get(pk=u.pk)
self.assertEqual(u.deactivate_type, event)
# Users start this test case with is_verified=True
# is_verified should only change if the modifying event
# is a block or drop
self.assertEqual(u.is_verified, event in STOP_SENDING)
self.assertFalse(u.opt_in_myjobs)
infos = u.messageinfo_set.all()
self.assertEqual(len(infos), 1)
message = infos[0].message
if u.deactivate_type in STOP_SENDING:
text = 'stop communications'
else:
text = 'Attempts to send messages to'
self.assertTrue(text in message.body)
EmailLog.objects.all().delete()
u.delete()
示例3: test_deleting_user_does_not_cascade
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import delete [as 别名]
def test_deleting_user_does_not_cascade(self):
"""
Deleting a user shouldn't delete related objects such as partner saved
searches and reports.
"""
user = UserFactory(email="[email protected]")
company = CompanyFactory()
pss = PartnerSavedSearchFactory(created_by=user)
report = Report.objects.create(created_by=user, owner=company)
user.delete()
self.assertIn(pss, PartnerSavedSearch.objects.all())
self.assertIn(report, Report.objects.all())
示例4: test_analytics_log_parsing
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import delete [as 别名]
def test_analytics_log_parsing(self):
"""
Ensure that analytics logs are parsed and stored in solr correctly
"""
company = CompanyFactory(id=1)
business_unit = BusinessUnitFactory(id=1000)
company.job_source_ids.add(business_unit)
# match and no_match will be used later to ensure that the correct
# number of documents were associated with a company or associated
# with the default company
match = Mock(
wraps=lambda: self.assertEqual(doc['company_id'], company.pk))
no_match = Mock(
wraps=lambda: self.assertEqual(doc['company_id'], 999999))
for log_type in ['analytics', 'redirect']:
log = MockLog(log_type=log_type)
parse_log([log], self.test_solr)
solr = Solr()
results = solr.search(q='uid:analytics*')
# fake logs contain two lines - one human and one bot hit
# If it is getting processed correctly, there should be only one
# hit recorded
self.assertEqual(results.hits, 1)
multi_field = 'facets'
if log_type == 'redirect':
with self.assertRaises(KeyError):
results.docs[0][multi_field]
else:
self.assertEqual(len(results.docs[0][multi_field]), 2)
for field in results.docs[0].keys():
if field != multi_field:
self.assertTrue(type(results.docs[0][field] != list))
uuid.UUID(results.docs[0]['aguid'])
with self.assertRaises(KeyError):
results.docs[0]['User_user_guid']
for doc in results.docs:
if doc['job_view_buid'] == business_unit.pk:
# If business units match, company ids should match
match()
else:
# Business units don't match; company id should be set to
# the default company
no_match()
solr.delete()
user = UserFactory(email="[email protected]")
user.user_guid = '1e5f7e122156483f98727366afe06e0b'
user.save()
parse_log([log], self.test_solr)
results = solr.search(q='uid:analytics*')
for guid in ['aguid', 'User_user_guid']:
uuid.UUID(results.docs[0][guid])
solr.delete()
user.delete()
# We have already determined that there are only two documents.
# Ensure that there is exactly one document that matches a specific
# company and one document that was given the default company
self.assertEqual(match.call_count, 1)
self.assertEqual(no_match.call_count, 1)