mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
		
			
				
	
	
		
			23 lines
		
	
	
		
			985 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			985 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from zerver.lib.onboarding import create_if_missing_realm_internal_bots
 | 
						|
from zerver.lib.test_classes import ZulipTestCase
 | 
						|
from zerver.models import Realm, UserProfile
 | 
						|
 | 
						|
 | 
						|
class TestRealmInternalBotCreation(ZulipTestCase):
 | 
						|
    def test_create_if_missing_realm_internal_bots(self) -> None:
 | 
						|
        realm_internal_bots_dict = [{'var_name': 'TEST_BOT',
 | 
						|
                                     'email_template': 'test-bot@%s',
 | 
						|
                                     'name': 'Test Bot'}]
 | 
						|
 | 
						|
        def check_test_bot_exists() -> bool:
 | 
						|
            all_realms_count = Realm.objects.count()
 | 
						|
            all_test_bot_count = UserProfile.objects.filter(
 | 
						|
                email='test-bot@zulip.com',
 | 
						|
            ).count()
 | 
						|
            return all_realms_count == all_test_bot_count
 | 
						|
 | 
						|
        self.assertFalse(check_test_bot_exists())
 | 
						|
        with self.settings(REALM_INTERNAL_BOTS=realm_internal_bots_dict):
 | 
						|
            create_if_missing_realm_internal_bots()
 | 
						|
        self.assertTrue(check_test_bot_exists())
 |