예제 #1
0
    def test_file_upload_limit(self):
        from dataent.utils.file_manager import MaxFileSizeReachedError
        from dataent.limits import update_limits, clear_limit
        from dataent import _dict

        update_limits({
            'space': 1,
            'space_usage': {
                'files_size': (1024**2),
                'database_size': 0,
                'backup_size': 0,
                'total': (1024**2)
            }
        })

        # Rebuild the dataent.local.conf to take up the changes from site_config
        dataent.local.conf = _dict(dataent.get_site_config())

        self.assertRaises(MaxFileSizeReachedError, save_file,
                          '_test_max_space.txt',
                          'This files test for max space usage', "", "",
                          self.get_folder("Test Folder 2", "Home").name)

        # Scrub the site_config and rebuild dataent.local.conf
        clear_limit("space")
        dataent.local.conf = _dict(dataent.get_site_config())
예제 #2
0
    def test_restrict_scheduler_events(self):
        dataent.set_user("Administrator")
        dormant_date = add_days(today(), -5)
        dataent.db.sql('update tabUser set last_active=%s', dormant_date)

        restrict_scheduler_events_if_dormant()
        dataent.local.conf = _dict(dataent.get_site_config())

        self.assertFalse("all" in get_enabled_scheduler_events())
        self.assertTrue(dataent.conf.get('dormant', False))

        clear_limit("expiry")
        dataent.local.conf = _dict(dataent.get_site_config())
예제 #3
0
	def test_user_limit_for_site_with_simultaneous_sessions(self):
		clear_limit('users')

		# make sure this user counts
		user = dataent.get_doc('User', '*****@*****.**')
		user.add_roles('Website Manager')
		user.save()

		update_limits({'users': get_total_users()})

		user.simultaneous_sessions = user.simultaneous_sessions + 1

		self.assertRaises(MaxUsersReachedError, user.save)

		# Clear the user limit
		clear_limit('users')
예제 #4
0
	def test_deactivate_additional_users(self):
		update_limits({'users': get_total_users()+1})

		if not dataent.db.exists("User", "*****@*****.**"):
			user = dataent.new_doc('User')
			user.email = '*****@*****.**'
			user.first_name = 'Test Deactivate Additional Users'
			user.add_roles("System Manager")

		#update limits
		update_limits({"users": get_total_users()-1})
		self.assertEqual(dataent.db.get_value("User", "*****@*****.**", "enabled"), 0)

		if dataent.db.exists("User", "*****@*****.**"):
			delete_contact('*****@*****.**')
			dataent.delete_doc('User', '*****@*****.**')

		# Clear the user limit
		clear_limit('users')
예제 #5
0
	def test_site_expiry(self):
		user = dataent.get_doc('User', '*****@*****.**')
		user.enabled = 1
		user.new_password = '******'
		user.save()

		update_limits({'expiry': add_to_date(today(), days=-1), 'support_email': '*****@*****.**'})
		dataent.local.conf = _dict(dataent.get_site_config())

		dataent.db.commit()

		res = requests.post(get_url(), params={'cmd': 'login', 'usr':
			'******', 'pwd': 'Eastern_43A1W', 'device': 'desktop'})

		# While site is expired status code returned is 417 Failed Expectation
		self.assertEqual(res.status_code, 417)

		clear_limit("expiry")
		dataent.local.conf = _dict(dataent.get_site_config())
예제 #6
0
	def test_user_limit_for_site(self):
		update_limits({'users': get_total_users()})

		# reload site config
		from dataent import _dict
		dataent.local.conf = _dict(dataent.get_site_config())

		# Create a new user
		user = dataent.new_doc('User')
		user.email = '*****@*****.**'
		user.first_name = 'Test_max_user'

		self.assertRaises(MaxUsersReachedError, user.add_roles, 'System Manager')

		if dataent.db.exists('User', '*****@*****.**'):
			delete_contact('*****@*****.**')
			dataent.delete_doc('User', '*****@*****.**')

		# Clear the user limit
		clear_limit('users')
예제 #7
0
    def test_disable_scheduler_on_expiry(self):
        update_limits({'expiry': add_to_date(today(), days=-1)})
        dataent.local.conf = _dict(dataent.get_site_config())

        if not dataent.db.exists('User', '*****@*****.**'):
            user = dataent.new_doc('User')
            user.email = '*****@*****.**'
            user.first_name = 'Test_scheduler'
            user.save()
            user.add_roles('System Manager')

        dataent.db.commit()
        dataent.set_user("*****@*****.**")

        disable_scheduler_on_expiry()

        ss = dataent.get_doc("System Settings")
        self.assertFalse(ss.enable_scheduler)

        clear_limit("expiry")
        dataent.local.conf = _dict(dataent.get_site_config())
예제 #8
0
def execute():
    limits = get_limits()
    if limits and limits.upgrade_link:
        upgrade_url = limits.upgrade_link
        clear_limit('upgrade_link')
        update_limits({'upgrade_url': upgrade_url})