本文整理汇总了Python中apps.fixmystreet.models.FMSUser.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python FMSUser.set_password方法的具体用法?Python FMSUser.set_password怎么用?Python FMSUser.set_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.fixmystreet.models.FMSUser
的用法示例。
在下文中一共展示了FMSUser.set_password方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReportProViewsTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class ReportProViewsTest(FMSTestCase):
def setUp(self):
self.user = User.objects.create_user(username="test1", email="[email protected]", password="test")
self.user.save()
self.client = Client()
self.citizen = FMSUser(
telephone="0123456789",
last_used_language="fr",
first_name="citizen",
last_name="citizen",
email="[email protected]",
)
self.citizen.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password="test",
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True,
)
self.manager.set_password("test")
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
self.super_user = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
first_name="superuser",
last_name="superuser",
email="[email protected]",
)
self.super_user.set_password("test")
self.super_user.is_superuser = True
self.super_user.save()
self.sample_post = {
"report-x": "150056.538",
"report-y": "170907.56",
"report-address_fr": "Avenue des Arts, 3",
"report-address_nl": "Kunstlaan, 3",
"report-address_number": "3",
"report-postalcode": "1210",
"report-category": "1",
"report-secondary_category": "1",
"report-subscription": "on",
"comment-text": "test",
"files-TOTAL_FORMS": 0,
"files-INITIAL_FORMS": 0,
"files-MAX_NUM_FORMS": 0,
"citizen-email": self.citizen.email,
"citizen-firstname": self.citizen.first_name,
"citizen-lastname": self.citizen.last_name,
"citizen-quality": "1",
"report-terms_of_use_validated": True,
}
示例2: test_previous_reports
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
def test_previous_reports(self):
self.client.login(username='[email protected]', password='test')
manager2 = FMSUser(
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager2",
last_name="manager2",
email="[email protected]",
manager=True
)
manager2.set_password('test')
manager2.organisation = self.organisation
manager2.save()
managerId = "manager_%s" % (manager2.id)
self.client.post(reverse("report_change_manager_pro", args=[self.report.id])+"?manId="+managerId)
self.assertEquals(len(self.manager.previous_reports.all()), 1)
self.assertEquals(self.manager.previous_reports.all()[0].id, self.report.id)
self.assertEquals(len(self.manager.reports_in_charge.all()), 0)
示例3: ValueUpdate
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class ValueUpdate(FMSTestCase):
def setUp(self):
self.secondary_category = ReportCategory.objects.all()[0]
self.category = self.secondary_category.category_class
# Create a FMSUser
self.etterbeek = OrganisationEntity.objects.get(id=5) # postal code = 1040 Etterbeek
self.etterbeek.save()
self.bxl = OrganisationEntity.objects.get(id=4) # postal code = 1000 Bxl
self.bxl.save()
self.manager_etterbeek = FMSUser(
email="[email protected]",
telephone="0123456789",
last_used_language="fr",
manager=True,
organisation=self.etterbeek,
)
self.manager_etterbeek.save()
self.manager_bxl = FMSUser(
email="[email protected]", telephone="0123456789", last_used_language="fr", manager=True, organisation=self.bxl
)
self.manager_bxl.save()
self.citizen = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr")
self.citizen.save()
self.client = Client()
self.manager = FMSUser(
telephone="0123456789",
last_used_language="fr",
password="test",
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True,
)
self.manager.set_password("test")
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
示例4: MailTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class MailTest(FMSTestCase):
def setUp(self):
self.citizen = FMSUser(
telephone="0123456789",
last_used_language="fr",
first_name="citizen",
last_name="citizen",
email="[email protected]"
)
self.citizen.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
self.manager4 = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager4",
last_name="manager4",
email="[email protected]",
manager=True
)
self.manager4.set_password('test')
self.manager4.organisation = OrganisationEntity.objects.get(pk=14)
self.manager4.save()
self.group = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=OrganisationEntity.objects.get(pk=14),
email="[email protected]"
)
self.group.save()
self.group.dispatch_categories.add(ReportCategory.objects.get(pk=1))
# Mail config: notify group and members in real time
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.group
self.group_mail_config.notify_group = True
self.group_mail_config.notify_members = True
self.group_mail_config.save()
self.manager.memberships.create(organisation=self.group, contact_user=True)
self.manager4.memberships.create(organisation=self.group, contact_user=True)
self.client = Client()
self.manager2 = FMSUser(
is_active=True,
telephone="9876543210",
last_used_language="nl",
password='test',
first_name="manager2",
last_name="manager2",
email="[email protected]",
manager=True
)
self.manager2.set_password('test2')
self.manager2.organisation = OrganisationEntity.objects.get(pk=14)
self.manager2.save()
self.group2 = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=OrganisationEntity.objects.get(pk=21),
email="[email protected]"
)
self.group2.save()
self.group2.dispatch_categories.add(ReportCategory.objects.get(pk=2))
self.group2.dispatch_categories.add(ReportCategory.objects.get(pk=1))
# Mail config: notify group and members in real time
self.group_mail_config2 = GroupMailConfig()
self.group_mail_config2.group = self.group2
self.group_mail_config2.notify_group = True
self.group_mail_config2.notify_members = True
self.group_mail_config2.save()
p1 = (148776, 171005)
p2 = (150776, 171005)
p3 = (150776, 169005)
p4 = (148776, 169005)
#.........这里部分代码省略.........
示例5: ReportViewsTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class ReportViewsTest(FMSTestCase):
def setUp(self):
self.user = FMSUser(username='test1', email='[email protected]', password='test')
self.user.save()
self.client = Client()
self.citizen = FMSUser(
telephone="0123456789",
last_used_language="fr",
first_name="citizen",
last_name="citizen",
email="[email protected]"
)
self.citizen.save()
self.group = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=OrganisationEntity.objects.get(pk=14),
email="[email protected]"
)
self.group.save()
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.group
self.group_mail_config.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
self.group.dispatch_categories.add(ReportCategory.objects.get(pk=1))
p1 = (148776, 171005)
p2 = (150776, 171005)
p3 = (150776, 169005)
p4 = (148776, 169005)
surface = OrganisationEntitySurface(
geom=Polygon([p1, p2, p3, p4, p1]),
owner=OrganisationEntity.objects.get(pk=14),
)
surface.save()
self.manager.memberships.create(organisation=self.group, contact_user=True)
self.sample_post = {
'report-x': '150056.538',
'report-y': '170907.56',
'report-address_fr': 'Avenue des Arts, 3',
'report-address_nl': 'Kunstlaan, 3',
'report-address_number': '3',
'report-postalcode': '1210',
'report-category': '1',
'report-secondary_category': '1',
'report-subscription': 'on',
'comment-text': 'test',
'files-TOTAL_FORMS': 0,
'files-INITIAL_FORMS': 0,
'files-MAX_NUM_FORMS': 0,
'citizen-email': self.citizen.email,
'citizen-firstname': self.citizen.first_name,
'citizen-lastname': self.citizen.last_name,
'citizen-quality': '1',
'report-terms_of_use_validated': True
}
self.sample_post_2 = {
'report-x': '150056',
'report-y': '170907.56',
'report-address_fr': 'Avenue des Arts, 3',
'report-address_nl': 'Kunstlaan, 3',
'report-address_number': '5',
'report-postalcode': '1210',
'report-category': '1',
'report-secondary_category': '1',
'report-subscription': 'on',
'comment-text': 'test2',
'files-TOTAL_FORMS': 0,
'files-INITIAL_FORMS': 0,
'files-MAX_NUM_FORMS': 0,
'citizen-email': self.citizen.email,
'citizen-firstname': self.citizen.first_name,
'citizen-lastname': self.citizen.last_name,
'citizen-quality': '1',
'report-terms_of_use_validated': True
}
#.........这里部分代码省略.........
示例6: UsersTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class UsersTest(FMSTestCase):
def setUp(self):
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
self.leader = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="leader",
last_name="leader",
email="[email protected]",
manager=True,
leader=True
)
self.leader.set_password('test')
self.leader.organisation = OrganisationEntity.objects.get(pk=14)
self.leader.save()
self.createuser_post = {
'telephone': '123456',
'is_active': True,
'first_name': 'david',
'last_name': 'hasselhof',
'email': '[email protected]'
}
self.edituser_post = {
'telephone': '654321',
'is_active': True,
'first_name': 'new_manager',
'last_name': 'new_manager',
'email': '[email protected]',
'manager': True
}
def testListUser(self):
self.client.login(username='[email protected]', password='test')
response = self.client.post(reverse('list_users'), follow=True)
self.assertEquals(response.status_code, 200)
self.assertTrue('users' in response.context)
self.assertTrue('can_create' in response.context)
can_create = response.context['can_create']
self.assertFalse(can_create)
#This user should not be able to create
users = response.context['users']
self.assertEquals(users.count(), 2)
self.assertIn(self.manager, users)
self.assertIn(self.leader, users)
#same result for leader
self.client.logout()
self.client.login(username='[email protected]', password='test')
response = self.client.post(reverse('list_users'), follow=True)
self.assertEquals(response.status_code, 200)
self.assertTrue('users' in response.context)
self.assertTrue('can_create' in response.context)
can_create = response.context['can_create']
self.assertTrue(can_create)
#This user should not be able to create
users = response.context['users']
self.assertEquals(users.count(), 2)
self.assertIn(self.manager, users)
self.assertIn(self.leader, users)
def testCreateUser(self):
self.client.login(username='[email protected]', password='test')
response = self.client.post(reverse('create_user'), self.createuser_post, follow=True)
self.assertEquals(response.status_code, 200)
response = self.client.post(reverse('list_users'), follow=True)
self.assertEquals(response.status_code, 200)
self.assertTrue('users' in response.context)
self.assertTrue('can_create' in response.context)
can_create = response.context['can_create']
users = response.context['users']
self.assertTrue(can_create)
self.assertEquals(users.count(), 3)
self.assertContains(response, self.createuser_post["email"])
new_user = FMSUser.objects.get(email=self.createuser_post['email'])
self.assertTrue(new_user.password)
self.assertNotEqual('!', new_user.password)
#self.assertEquals(len(mail.outbox), 1)
def testUpdateLeaderAsLeader(self):
self.client.login(username='[email protected]', password='test')
response = self.client.post(reverse('edit_user', args=[self.leader.id]), self.edituser_post, follow=True)
self.assertEquals(response.status_code, 200)
self.assertTrue('can_edit' in response.context)
#.........这里部分代码省略.........
示例7: ReopenRequestTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class ReopenRequestTest(FMSTestCase):
def setUp(self):
self.citizen = FMSUser(
telephone="0123456789",
last_used_language="fr",
first_name="citizen",
last_name="citizen",
email="[email protected]"
)
self.citizen.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
self.group = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=OrganisationEntity.objects.get(pk=14),
email="[email protected]"
)
self.group.save()
self.group.dispatch_categories.add(ReportCategory.objects.get(pk=1))
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.group
self.group_mail_config.save()
self.manager.memberships.create(organisation=self.group, contact_user=True)
self.client = Client()
self.manager2 = FMSUser(
is_active=True,
telephone="9876543210",
last_used_language="nl",
password='test',
first_name="manager2",
last_name="manager2",
email="[email protected]",
manager=True
)
self.manager2.set_password('test2')
self.manager2.organisation = OrganisationEntity.objects.get(pk=14)
self.manager2.save()
self.group2 = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=OrganisationEntity.objects.get(pk=21),
email="[email protected]"
)
self.group2.save()
self.group2.dispatch_categories.add(ReportCategory.objects.get(pk=2))
self.group2.dispatch_categories.add(ReportCategory.objects.get(pk=1))
p1 = (148776, 171005)
p2 = (150776, 171005)
p3 = (150776, 169005)
p4 = (148776, 169005)
surface = OrganisationEntitySurface(
geom=Polygon([p1, p2, p3, p4, p1]),
owner=OrganisationEntity.objects.get(pk=14),
)
surface.save()
self.manager2.memberships.create(organisation=self.group2)
self.manager3 = FMSUser(
is_active=True,
telephone="000000000",
last_used_language="nl",
password='test',
first_name="manager3",
last_name="manager3",
email="[email protected]",
manager=True
)
self.manager3.set_password('test3')
self.manager3.organisation = OrganisationEntity.objects.get(pk=21)
self.manager3.save()
self.manager3.memberships.create(organisation=self.group2)
self.impetrant = OrganisationEntity(
#.........这里部分代码省略.........
示例8: GroupsTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class GroupsTest(FMSTestCase):
def setUp(self):
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
self.leader = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="leader",
last_name="leader",
email="[email protected]",
manager=True,
leader=True
)
self.leader.set_password('test')
self.leader.organisation = OrganisationEntity.objects.get(pk=14)
self.leader.save()
self.group1 = OrganisationEntity(
name_fr="groupe1",
name_nl="groep1",
phone="00000000",
email="[email protected]",
type='D',
dependency=OrganisationEntity.objects.get(pk=14)
)
self.group1.save()
self.group_mail_config1 = GroupMailConfig()
self.group_mail_config1.group = self.group1
self.group_mail_config1.save()
self.group2 = OrganisationEntity(
name_fr="groupe2",
name_nl="groep2",
phone="00000000",
email="[email protected]",
type='D',
dependency=OrganisationEntity.objects.get(pk=11)
)
self.group2.save()
self.group_mail_config2 = GroupMailConfig()
self.group_mail_config2.group = self.group2
self.group_mail_config2.save()
self.creategroup_post = {
'name_fr': 'groupe3',
'name_nl': 'groep3',
'phone': '0000000000',
'email': '[email protected]',
'type': 'D',
'notify_group': True
}
self.creategroup_post2 = {
'name_fr': 'groupe4',
'name_nl': 'groep4',
'phone': '0000000000',
'email': '[email protected]',
'type': 'S',
'notify_group': True
}
self.editgroup_post = {
'name_fr': 'groupe1nouveau',
'name_nl': 'groep1nieuw',
'phone': '111111',
'email': '[email protected]',
'type': 'D',
### Mail Config ###
'groupmailconfig-TOTAL_FORMS' : u'1',
'groupmailconfig-INITIAL_FORMS' : u'1',
'groupmailconfig-MAX_NUM_FORMS' : u'1',
'groupmailconfig-0-notify_group' : True,
'groupmailconfig-0-notify_members' : True,
'groupmailconfig-0-digest_created' : True,
'groupmailconfig-0-digest_inprogress' : True,
'groupmailconfig-0-digest_closed' : True,
'groupmailconfig-0-digest_other' : True,
}
self.editgroup_post2 = {
'name_fr': 'groupe2nouveau',
'name_nl': 'groep2nieuw',
#.........这里部分代码省略.........
示例9: ApiTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class ApiTest(FMSTestCase):
def setUp(self):
try:
organisation = OrganisationEntity.objects.get(id=1)
except ObjectDoesNotExist:
organisation = OrganisationEntity(id=1, name="Test organisation")
organisation.save()
p1 = (148776, 171005)
p2 = (150776, 171005)
p3 = (150776, 169005)
p4 = (148776, 169005)
surface = OrganisationEntitySurface(
geom=Polygon([p1, p2, p3, p4, p1]),
owner=OrganisationEntity.objects.get(pk=14)
)
surface.save()
#user_auth = User.objects.create_user(username='superuser', email='[email protected]', password='test')
#user_auth.save()
user = FMSUser(
is_active=True,
password="test",
email="[email protected]",
first_name="zaza",
telephone="00000000",
last_used_language="fr",
organisation=organisation,
username='superuser')
user.save()
#~ main_category = ReportMainCategoryClass(id=2,name_en='test main en',name_nl='test main nl',name_fr='test main fr')
#~ main_category.save()
#~
#~ secondary_category = ReportSecondaryCategoryClass(id=2,name_en='test second en',name_nl='test second nl',name_fr='test second fr')
#~ secondary_category.save()
#~
#~ category = ReportCategory(id=2,name_en='test parent en',name_nl='test parent nl',name_fr='test parent fr', public=True, category_class=main_category, secondary_category_class=secondary_category)
#~ category.save()
self.citizen = FMSUser(
telephone="0123456789",
last_used_language="fr",
first_name="citizen",
last_name="citizen",
email="[email protected]"
)
self.citizen.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
self.group = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=OrganisationEntity.objects.get(pk=14),
email="[email protected]"
)
self.group.save()
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.group
self.group_mail_config.save()
self.usergroupmembership = UserOrganisationMembership(user_id=self.manager.id, organisation_id=self.group.id, contact_user=True)
self.usergroupmembership.save()
self.sample_post = {
'report-x': '150056.538',
'report-y': '170907.56',
'report-address_fr': 'Avenue des Arts, 3',
'report-address_nl': 'Kunstlaan, 3',
'report-address_number': '3',
'report-postalcode': '1210',
'report-category': '1',
'report-secondary_category': '1',
'report-subscription': 'on',
'report-terms_of_use_validated': True,
'comment-text': 'test',
'files-TOTAL_FORMS': 0,
'files-INITIAL_FORMS': 0,
'files-MAX_NUM_FORMS': 1000,
#.........这里部分代码省略.........
示例10: DispatchingTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class DispatchingTest(FMSTestCase):
def setUp(self):
self.client = Client()
self.secondary_category = ReportCategory.objects.all()[0]
self.category = self.secondary_category.category_class
self.organisation = OrganisationEntity.objects.get(pk=4)
self.department = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=self.organisation,
email="[email protected]"
)
self.department.save()
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.department
self.group_mail_config.save()
p1 = (148776, 171005)
p2 = (150776, 171005)
p3 = (150776, 169005)
p4 = (148776, 169005)
surface = OrganisationEntitySurface(
geom=Polygon([p1, p2, p3, p4, p1]),
owner=self.organisation,
)
surface.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = self.organisation
self.manager.save()
self.department.dispatch_categories.add(self.secondary_category)
self.usergroupmembership = UserOrganisationMembership(user=self.manager, organisation=self.department, contact_user=True)
self.usergroupmembership.save()
self.applicant_group = OrganisationEntity(
type="A",
name_nl="Belgacom",
name_fr="Belgacom",
phone="090987",
email="[email protected]"
)
self.applicant_group.save()
self.applicant = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.applicant.set_password('test')
self.applicant.save()
self.applicantmembership = UserOrganisationMembership(user=self.applicant, organisation=self.applicant_group, contact_user=True)
self.applicantmembership.save()
def test_dispatch_pro(self):
"""
when a report is created by a agent / manager / entity
responsible entity is computed based on responsible entity from creator
"""
self.client.login(username='[email protected]', password='test')
self.report = Report(
status=Report.CREATED,
secondary_category=self.secondary_category,
category=self.category,
description='Just a test',
postalcode=1090,
address='my address',
point=dict_to_point({"x": '149776', "y": '170005'}),
address_number='6h',
created_by=self.manager,
accepted_at=datetime.now()
)
self.report.save()
self.assertEquals(self.report.responsible_entity, self.organisation)
self.assertEquals(self.report.responsible_department, self.department)
def test_dispatch_applicant(self):
#.........这里部分代码省略.........
示例11: HistoryTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class HistoryTest(FMSTestCase):
def setUp(self):
self.citizen = FMSUser(
telephone="0123456789",
last_used_language="fr",
first_name="Fake first name",
last_name="Fake last name",
email="[email protected]"
)
self.citizen.save()
self.citizen2 = FMSUser(
telephone="9876543210",
last_used_language="nl",
first_name="Fake first name2",
last_name="Fake last name2",
email="[email protected]"
)
self.citizen2.save()
self.citizen3 = FMSUser(
telephone="5649783210",
last_used_language="nl",
first_name="Fake first name3",
last_name="Fake last name3",
email="[email protected]"
)
self.citizen3.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = OrganisationEntity.objects.get(pk=14)
self.manager.save()
p1 = (148776, 171005)
p2 = (150776, 171005)
p3 = (150776, 169005)
p4 = (148776, 169005)
surface = OrganisationEntitySurface(
geom=Polygon([p1, p2, p3, p4, p1]),
owner=OrganisationEntity.objects.get(pk=14),
)
surface.save()
self.group = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=OrganisationEntity.objects.get(pk=14),
email="[email protected]"
)
self.group.save()
self.group.dispatch_categories.add(ReportCategory.objects.get(pk=1))
self.group.dispatch_categories.add(ReportCategory.objects.get(pk=2))
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.group
self.group_mail_config.save()
self.manager.memberships.create(organisation=self.group, contact_user=True)
self.manager2 = FMSUser(
is_active=True,
telephone="9876543210",
last_used_language="nl",
password='test',
first_name="manager2",
last_name="manager2",
email="[email protected]",
manager=True
)
self.manager2.set_password('test2')
self.manager2.organisation = OrganisationEntity.objects.get(pk=14)
self.manager2.save()
self.manager2.memberships.create(organisation=self.group)
self.manager3 = FMSUser(
is_active=True,
telephone="000000000",
last_used_language="nl",
password='test',
first_name="manager3",
last_name="manager3",
email="[email protected]",
manager=True
)
self.manager3.set_password('test3')
self.manager3.organisation = OrganisationEntity.objects.get(pk=21)
self.manager3.save()
#.........这里部分代码省略.........
示例12: UpdatesTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class UpdatesTest(FMSTestCase):
def setUp(self):
self.client = Client()
self.secondary_category = ReportCategory.objects.all()[0]
self.category = self.secondary_category.category_class
self.organisation = OrganisationEntity.objects.get(pk=14)
self.organisation2 = OrganisationEntity.objects.get(pk=15)
self.group = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=self.organisation,
email="[email protected]"
)
self.group.save()
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.group
self.group_mail_config.save()
self.group2 = OrganisationEntity(
type="D",
name_nl="Werken2",
name_fr="Travaux2",
phone="090987",
dependency=self.organisation2,
email="[email protected]"
)
self.group2.save()
self.group_mail_config2 = GroupMailConfig()
self.group_mail_config2.group = self.group2
self.group_mail_config2.save()
self.manager = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager",
last_name="manager",
email="[email protected]",
manager=True
)
self.manager.set_password('test')
self.manager.organisation = self.organisation
self.manager.save()
self.manager2 = FMSUser(
is_active=True,
telephone="0123456789",
last_used_language="fr",
password='test',
first_name="manager2",
last_name="manager2",
email="[email protected]",
manager=True
)
self.manager2.set_password('test')
self.manager2.organisation = self.organisation
self.manager2.save()
self.usergroupmembership = UserOrganisationMembership(user_id=self.manager.id, organisation_id=self.group.id, contact_user=True)
self.usergroupmembership.save()
self.usergroupmembership = UserOrganisationMembership(user_id=self.manager2.id, organisation_id=self.group2.id, contact_user=True)
self.usergroupmembership.save()
self.report = Report(
status=Report.CREATED,
secondary_category=self.secondary_category,
category=self.category,
description='Just a test',
postalcode=1000,
address='my address',
point=dict_to_point({"x": '149776', "y": '170005'}),
address_number='6h',
created_by=self.manager,
accepted_at=datetime.now()
)
self.report.save()
def test_change_manager(self):
"""Tests manager change assigned to a report and test the view of it."""
report = self.report
report.responsible_department = self.group
report.save()
self.client.login(username='[email protected]', password='test')
"""Change manager department"""
url = reverse('report_change_manager_pro', args=[report.id])
response = self.client.get("{0}?manId=department_{1}".format(url, self.group2.id), follow=True)
self.assertEqual(response.status_code, 200)
#.........这里部分代码省略.........
示例13: ExportPDFTest
# 需要导入模块: from apps.fixmystreet.models import FMSUser [as 别名]
# 或者: from apps.fixmystreet.models.FMSUser import set_password [as 别名]
class ExportPDFTest(FMSTestCase):
def setUp(self):
self.bxl = OrganisationEntity.objects.get(id=4)
self.manager_bxl = FMSUser(
is_active=True,
email="[email protected]",
telephone="0123456789",
last_used_language="fr",
manager=True,
organisation=self.bxl)
self.manager_bxl.set_password('test')
self.manager_bxl.save()
self.group = OrganisationEntity(
type="D",
name_nl="Werken",
name_fr="Travaux",
phone="090987",
dependency=self.bxl,
email="[email protected]"
)
self.group.save()
self.group_mail_config = GroupMailConfig()
self.group_mail_config.group = self.group
self.group_mail_config.save()
self.usergroupmembership = UserOrganisationMembership(user_id=self.manager_bxl.id, organisation_id=self.group.id, contact_user=True)
self.usergroupmembership.save()
self.citizen = FMSUser(email="[email protected]", telephone="0123456789", last_used_language="fr")
self.citizen.save()
self.secondary_category = ReportCategory.objects.all()[0]
self.category = self.secondary_category.category_class
self.client.login(username=self.manager_bxl.email, password='test')
self.report = Report(
status=Report.CREATED,
secondary_category=self.secondary_category,
category=self.category,
description='Just a test',
postalcode=1000,
address='my address',
point=dict_to_point({"x": '149776', "y": '170005'}),
address_number='6h',
created_by=self.manager_bxl
)
self.report.save()
self.report.attachments.add(ReportComment(
text='test comment 1',
security_level=ReportComment.PRIVATE
))
self.client.logout()
self.report.attachments.add(ReportComment(
text='test comment 2',
security_level=ReportComment.PUBLIC
))
self.report.attachments.add(ReportComment(
text='test comment 3',
logical_deleted=True,
security_level=ReportComment.PUBLIC
))
self.client = Client()
def test_pdf_attachment(self):
response = self.client.get(reverse('report_pdf', args=[self.report.id]) + '?output=html', follow=True)
self.assertEqual(response.status_code, 200)
self.assertIn('comments', response.context)
self.assertEqual(len(response.context['comments']), 1)
self.assertEqual(response.context['comments'][0].text, 'test comment 2')
self.assertEqual(response.context['visibility'], 'public')
def test_attachment_private(self):
self.assertTrue(self.client.login(username=self.manager_bxl.email, password='test'))
response = self.client.get(reverse('report_pdf_pro', args=[self.report.id]) + '?output=html', follow=True)
self.assertEqual(response.status_code, 200)
self.assertTrue(hasattr(response.context['request'], 'fmsuser'))
self.assertIn('comments', response.context)
self.assertEqual(len(response.context['comments']), 2)
self.assertEqual(response.context['comments'][0].text, 'test comment 1')
self.assertEqual(response.context['comments'][1].text, 'test comment 2')
self.assertEqual(response.context['visibility'], 'private')
def test_show_attachment(self):
response = self.client.get(reverse('report_show', kwargs={'report_id': self.report.id, 'slug': ''}), follow=True)
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, 'test comment 1')
self.assertContains(response, 'test comment 2')
self.assertNotContains(response, 'test comment 3')
def test_show_attachment_private(self):
self.assertTrue(self.client.login(username=self.manager_bxl.email, password='test'))
#.........这里部分代码省略.........