コード例 #1
0
    def setUpTestData(cls):
        """
        Creates a user and logs it in before running the actual tests.
        """
        password = '******'
        set_current_user(None)

        # Set the anonymous user on the class.
        cls.anonymous_user_obj = AnonymousUser()
        cls.anonymous_user = APIClient()

        tenant_1 = TenantFactory.create()
        tenant_2 = TenantFactory.create()

        # Set the authenticated user on the class.
        cls.user_obj = LilyUser.objects.create_user(
            email='*****@*****.**',
            password=password,
            tenant_id=tenant_1.id
        )

        account_admin = Group.objects.get_or_create(name='account_admin')[0]
        cls.user_obj.groups.add(account_admin)

        cls.user_obj.info = UserInfo.objects.create(
            registration_finished=True
        )
        cls.user_obj.save()

        cls.user = APIClient()
        cls.user.login(username=cls.user_obj.email, password=password)

        # Set the superuser on the class.
        cls.superuser_obj = LilyUser.objects.create_superuser(
            email='*****@*****.**',
            password=password,
            tenant_id=tenant_1.id
        )
        cls.superuser_obj.info = UserInfo.objects.create(
            registration_finished=True
        )
        cls.superuser_obj.save()

        cls.superuser = APIClient()
        cls.superuser.login(username=cls.superuser_obj.email, password=password)

        # Set the authenticated user from another tenant on the class.
        cls.other_tenant_user_obj = LilyUser.objects.create_user(
            email='*****@*****.**',
            password=password,
            tenant_id=tenant_2.id
        )
        cls.other_tenant_user_obj.info = UserInfo.objects.create(
            registration_finished=True
        )
        cls.other_tenant_user_obj.save()

        cls.other_tenant_user = APIClient()
        cls.other_tenant_user.login(username=cls.other_tenant_user_obj.email, password=password)
コード例 #2
0
ファイル: test_model.py プロジェクト: ernsyn/hellolily
    def setUp(self):
        # Reset changes made to the email account in a test.
        self.email_account.refresh_from_db()

        self.tenant = TenantFactory.create()
        self.users = LilyUserFactory.create_batch(size=3)
        self.owner = self.users[0]
コード例 #3
0
ファイル: tests.py プロジェクト: yorik-freecad-blog/hellolily
    def test_update_modified(self):
        """
        Test that the modified date of a case gets set properly.
        """
        tenant = TenantFactory.create()
        note = NoteFactory.create(tenant=tenant)
        modified = note.modified

        time.sleep(1)

        note.save(update_modified=False)
        self.assertEqual(modified, note.modified)

        note.save(update_modified=True)
        self.assertNotEqual(modified, note.modified)
コード例 #4
0
    def setUpClass(cls):
        """
        Creates a user and logs it in before running the actual tests.
        """
        password = '******'
        set_current_user(None)

        # Set the anonymous user on the class.
        cls.anonymous_user_obj = AnonymousUser()
        cls.anonymous_user = APIClient()

        tenant_1 = TenantFactory.create()
        tenant_2 = TenantFactory.create()

        # Set the authenticated user on the class.
        cls.user_obj = LilyUser.objects.create_user(email='*****@*****.**', password=password, tenant_id=tenant_1.id)
        cls.user = APIClient()
        cls.user.login(email=cls.user_obj.email, password=password)

        # Set the superuser on the class.
        cls.superuser_obj = LilyUser.objects.create_superuser(
            email='*****@*****.**',
            password=password,
            tenant_id=tenant_1.id
        )
        cls.superuser = APIClient()
        cls.superuser.login(email=cls.superuser_obj.email, password=password)

        # Set the authenticated user from another tenant on the class.
        cls.other_tenant_user_obj = LilyUser.objects.create_user(
            email='*****@*****.**',
            password=password,
            tenant_id=tenant_2.id
        )
        cls.other_tenant_user = APIClient()
        cls.other_tenant_user.login(email=cls.other_tenant_user_obj.email, password=password)