コード例 #1
0
def create_test_directory(testdir):
    file_manager.create_directory(path_list=[testdir], add_init=True)
    file_manager.create_directory(path_list=[testdir, 'projects'],
                                  add_init=True)
    file_manager.create_directory(path_list=[testdir, 'drivers'],
                                  add_init=False)
    settings_manager.create_global_settings_file(testdir)
    create_testdir_golem_file(testdir)
    session.testdir = testdir
    Users.create_super_user('admin', 'admin')
コード例 #2
0
ファイル: commands.py プロジェクト: pelgabalawy/golem
def createsuperuser_command(username, email, password, no_input=False):
    if no_input:
        if username is None or password is None:
            sys.exit(
                'Error: --username and --password are required for --noinput.')
    else:
        try:
            while True:
                username = input('Username: '******'Email address (optional): ').strip()
                if email and not utils.validate_email(email):
                    print('Error: Enter a valid email address.')
                else:
                    break
            while True:
                password = input('Password: '******'Password (again): ')
                if not len(password):
                    print('Error: Blank passwords are not allowed.')
                elif password != repeat_password:
                    print('Error: The passwords did not match.')
                else:
                    break
        except KeyboardInterrupt:
            sys.exit('Cancelled.')
    errors = Users.create_super_user(username, password, email)
    if errors:
        for error in errors:
            print('Error: {}'.format(error))
        exit(1)
    else:
        print('Superuser {} was created successfully.'.format(username))
コード例 #3
0
 def test_create_super_user(self, testdir_function, test_utils):
     testdir_function.activate()
     username = test_utils.random_string(10)
     Users.create_super_user(username, '123456')
     user = Users.get_user_by_username(username)
     assert user.is_superuser