本文整理汇总了Python中models.Profile.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.set_password方法的具体用法?Python Profile.set_password怎么用?Python Profile.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.set_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMongoORMInfrastructure
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import set_password [as 别名]
class TestMongoORMInfrastructure(TestCase):
def setUp(self):
self.user = Profile()
self.user.username = 'testuser'
self.user.company_name = 'Test Company'
self.user.set_password('testuser')
self.user.save()
self.acc = AnalyticsAccount(user = self.user)
self.acc.pk = 10000
self.acc.name = 'Test'
self.acc.analytics_id = 'asd324sf456m6n76b5b'
self.acc.history_fetched = False
self.acc.save()
self.other_acc = AnalyticsAccount(user = self.user)
self.other_acc.pk = 10001
self.other_acc.name = 'Test1'
self.other_acc.analytics_id = 'asd324sf456m111111'
self.other_acc.history_fetched = False
self.other_acc.save()
self.list_of_accounts=[self.acc, self.other_acc]
records = []
records.append({"start_date":datetime(2005, 7, 28), "values":[], "some_id":2,})
records.append({"start_date":datetime(2005, 8, 28), "values":[], "some_id":2,})
records.append({"start_date":datetime(2005, 8, 28), "values":[], "some_id":3,})
self.the_records = records
TestModel1.objects.all().delete()
self.assertEqual(TestModel1.objects.all().count(), 0)
TestModel2.objects.all().delete()
self.assertEqual(TestModel2.objects.all().count(), 0)
TestModel3.objects.all().delete()
self.assertEqual(TestModel3.objects.all().count(), 0)
TestModel1.objects.bulk_insert(self.the_records)
self.assertEqual(TestModel1.objects.all().count(), len(self.the_records))
tm1a = TestModel1.objects.get(start_date = datetime(2005, 7, 28, tzinfo=timezone.utc), some_id =2)
# Creating on object from TestModel2 referencing an object from TestModel1
tm2a = TestModel2(ref1= tm1a, start_date = datetime(2005, 8, 12), values=[1, 3], some_id =12)
tm2a.save()
self.assertEqual(TestModel2.objects.all().count(), 1)
# Creating on object from TestModel3 wo reference
tm3a = TestModel3(start_date = datetime(2005, 8, 12), values=[1, 3], some_id =12)
tm3a.save()
self.assertEqual(TestModel3.objects.all().count(), 1)
# Creating on object from TestModel3 with reference
tm1b = TestModel1.objects.get(start_date = datetime(2005, 8, 28, tzinfo=timezone.utc), some_id =3)
tm2b = TestModel2(ref1= tm1b, start_date = datetime(2005, 8, 13), values=[1, 3], some_id =13)
tm2b.save()
tm3b = TestModel3( ref2= tm2b, start_date = datetime(2005, 8, 12), values=[1, 3], some_id =14)
tm3b.save()
self.assertEqual(TestModel3.objects.all().count(), 2)
self.assertEqual(TestModel2.objects.all().count(), 2)
def test_delete_non_referenced_object(self):
pre1 = TestModel1.objects.all().count()
self.assertNotEqual(pre1, 0)
pre2 = TestModel2.objects.all().count()
self.assertNotEqual(pre2, 0)
pre3 = TestModel3.objects.all().count()
self.assertNotEqual(pre3, 0)
TestModel1.objects.filter(start_date = datetime(2005, 8, 28, tzinfo=timezone.utc), some_id =3).delete()
self.assertEqual(TestModel1.objects.all().count(), pre1-1)
self.assertEqual(pre2, TestModel2.objects.all().count())
self.assertEqual(pre3, TestModel3.objects.all().count())
def test_delete_referenced_object_m1_m2_with_cascade(self):
pre1 = TestModel1.objects.all().count()
self.assertNotEqual(pre1, 0)
pre2 = TestModel2.objects.all().count()
self.assertNotEqual(pre2, 0)
pre3 = TestModel3.objects.all().count()
self.assertNotEqual(pre3, 0)
tm1o = TestModel1.objects.get(start_date = datetime(2005, 7, 28, tzinfo=timezone.utc), some_id =2)
tm1o.delete()
self.assertEqual(TestModel1.objects.all().count(), pre1-1)
self.assertEqual(TestModel2.objects.all().count(), pre2-1)
self.assertEqual(pre3, TestModel3.objects.all().count())
def test_delete_of_queryset(self):
pre1 = TestModel1.objects.all().count()
self.assertNotEqual(pre1, 0)
pre2 = TestModel2.objects.all().count()
self.assertNotEqual(pre2, 0)
pre3 = TestModel3.objects.all().count()
#.........这里部分代码省略.........
示例2: TestMongoQuerySetWithUniqueVisits
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import set_password [as 别名]
class TestMongoQuerySetWithUniqueVisits(TestCase):
def setUp(self):
self.user = Profile()
self.user.username = 'testuser'
self.user.company_name = 'Test Company'
self.user.set_password('testuser')
self.user.save()
self.acc = AnalyticsAccount(user = self.user)
self.acc.pk = 10000
self.acc.name = 'Test'
self.acc.analytics_id = 'asd324sf456m6n76b5b'
self.acc.history_fetched = False
self.acc.save()
self.other_acc = AnalyticsAccount(user = self.user)
self.other_acc.pk = 10001
self.other_acc.name = 'Test1'
self.other_acc.analytics_id = 'asd324sf456m111111'
self.other_acc.history_fetched = False
self.other_acc.save()
self.list_of_accounts = [self.acc, self.other_acc]
records = []
class NumberLong():
def __init__(self, num):
self.n = num
records.append({ "goal_starts" : { }, "time_on_site" : 17, "user_id" : 650825334, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "Tennessee",
"ct" : "Clarksville" }, "demographics" :
{ "age" : "GenX (25-44)", "education" : "High School" }, "first_visit_date" :
ISODate("2012-08-04T21:18:17Z"), "referral_path" : "(not set)", "source" : "google", "exit_page_path" :
"/some-analysis/g1iar-daisy/", "landing_page_path" : "(not set)", "keyword" :
"g1iar daisy sparknotes", "date" : ISODate("2012-08-04T00:00:00Z"), "goal_completions" : { },
"visit_count" : 1, "visit_id" : "0---30----0---------------650825334.1344115097",
"page_views" : 3, "goal_values" : { } })
records.append({ "goal_starts" : { }, "time_on_site" : 36, "user_id" : 277227593, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "Tennessee",
"ct" : "Sevierville" }, "demographics" :
{ "gender" : "Men", "education" : "High School" }, "first_visit_date" :
ISODate("2012-08-06T14:46:23Z"), "referral_path" : "(not set)", "source" : "google", "exit_page_path" :
"/some-analysis/looking-at-my-ancestors/", "landing_page_path" : "(not set)", "keyword" :
"(not provided)", "date" : ISODate("2012-08-06T00:00:00Z"), "goal_completions" : { }, "visit_count" : 1,
"visit_id" : "0-2--0-1---1---------------277227593.1344264383", "page_views" : 1,
"goal_values" : { } })
records.append({ "goal_starts" : { }, "time_on_site" : 27, "user_id" : 1429730596, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "Virginia",
"ct" : "Burke" }, "demographics" :
{ "gender" : "Men", "age" : "Baby Boomers (45-70)", "education" : "High School" },
"first_visit_date" : ISODate("2012-08-06T04:28:22Z"), "referral_path" : "(not set)", "source" :
"google", "exit_page_path" : "/some-analysis/the_double-blind/", "landing_page_path" : "(not set)",
"keyword" : "(not provided)", "date" : ISODate("2012-08-06T00:00:00Z"), "goal_completions" :
{ }, "visit_count" : 1, "visit_id" : "0-2-90-1--0---------------1429730596.1344227302",
"page_views" : 3, "goal_values" : { } })
records.append({ "goal_starts" : { }, "time_on_site" : 27, "user_id" : 2110905334, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "New York",
"ct" : "Poughkeepsie" }, "demographics" :
{ "gender" : "Men", "education" : "High School", "political" : "Democrats" }, "first_visit_date" :
ISODate("2012-08-06T18:21:11Z"), "referral_path" : "(not set)", "source" : "yahoo", "exit_page_path" :
"/some-analysis/joe-and-bobby/", "landing_page_path" : "(not set)", "keyword" :
"book summaries", "date" : ISODate("2012-08-06T00:00:00Z"), "goal_completions" : { },
"visit_count" : 1, "visit_id" : "0-0--0-1---------------2110905334.1344277271",
"page_views" : 1, "goal_values" : { } })
records.append({ "goal_starts" : { }, "time_on_site" : 120, "user_id" : 952676001, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "Massachusetts",
"ct" : "Abington" }, "demographics" :
{ "age" : "GenX (25-44)", "education" : "High School" },
"first_visit_date" : ISODate("2012-08-06T05:53:52Z"), "referral_path" : "(not set)",
"source" : "google", "exit_page_path" : "/some-analysis/the-blue-bush/",
"landing_page_path" : "(not set)", "keyword" : "(not provided)",
"date" : ISODate("2012-08-06T00:00:00Z"), "goal_completions" : { }, "visit_count" : 1,
"visit_id" : "0---30---------------952676001.1344232432", "page_views" : 3,
"goal_values" : { } })
records.append({ "goal_starts" : { }, "time_on_site" : 10, "user_id" : 805172613, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "New York",
"ct" : "Peekskill" }, "demographics" :
{ "age" : "GenX (25-44)", "education" : "High School" }, "first_visit_date" :
ISODate("2012-08-06T16:27:55Z"), "referral_path" : "(not set)", "source" : "bing", "exit_page_path" :
"/wikipedia/rama-ii/", "landing_page_path" : "(not set)", "keyword" : "research rama ii", "date" :
ISODate("2012-08-06T00:00:00Z"), "goal_completions" : { }, "visit_count" : 2, "visit_id" :
"0---30---------------805172613.1344270475", "page_views" : 2, "goal_values" : { } })
records.append({ "goal_starts" : { }, "time_on_site" : 147, "user_id" : 2060101123, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "South Carolina", "ct" :
"Charleston" }, "demographics" : { "age" : "GenX (25-44)", "education" : "High School" },
"first_visit_date" : ISODate("2012-08-06T02:04:05Z"), "referral_path" : "(not set)", "source" :
"google", "exit_page_path" : "/search", "landing_page_path" : "(not set)", "keyword" :
"a short reference", "date" : ISODate("2012-08-06T00:00:00Z"), "goal_completions" : { },
"visit_count" : 1, "visit_id" : "0-2-30---------------2060101123.1344218645",
"page_views" : 3, "goal_values" : { } })
records.append({ "goal_starts" : { }, "time_on_site" : 25, "user_id" : 1525231829, "account_id" : NumberLong(5),
"campaign" : "(not set)", "location" : { "cr" : "United States", "rg" : "New York", "ct" :
"Massapequa" }, "demographics" : { "age" : "GenX (25-44)", "education" : "High School" },
"first_visit_date" : ISODate("2012-08-05T14:57:17Z"), "referral_path" : "(not set)", "source" :
"google", "exit_page_path" : "/wikipedia/indian-reservations/", "landing_page_path" : "(not set)", "keyword" :
#.........这里部分代码省略.........