faker_file.tests package

Submodules

faker_file.tests.data module

faker_file.tests.sftp_server module

class faker_file.tests.sftp_server.SFTPServer(conn: SSHServerChannel)[source]

Bases: SFTPServer

class faker_file.tests.sftp_server.SFTPServerManager(host: str = '0.0.0.0', port: int = 2222)[source]

Bases: object

start() None[source]
async start_server() None[source]
stop() None[source]
class faker_file.tests.sftp_server.SSHServer(connection_semaphore: Semaphore)[source]

Bases: SSHServer

auth_completed() None[source]

Authentication was completed successfully

This method is called when authentication has completed succesfully. Applications may use this method to perform processing based on the authenticated username or options in the authorized keys list or certificate associated with the user before any sessions are opened or forwarding requests are handled.

async begin_auth(username: str) bool[source]

Authentication has been requested by the client

This method will be called when authentication is attempted for the specified user. Applications should use this method to prepare whatever state they need to complete the authentication, such as loading in the set of authorized keys for that user. If no authentication is required for this user, this method should return False to cause the authentication to immediately succeed. Otherwise, it should return True to indicate that authentication should proceed.

If blocking operations need to be performed to prepare the state needed to complete the authentication, this method may be defined as a coroutine.

Parameters:

username (str) – The name of the user being authenticated

Returns:

A bool indicating whether authentication is required

password_auth_supported() bool[source]

Return whether or not password authentication is supported

This method should return True if password authentication is supported. Applications wishing to support it must have this method return True and implement validate_password() to return whether or not the password provided by the client is valid for the user being authenticated.

By default, this method returns False indicating that password authentication is not supported.

Returns:

A bool indicating if password authentication is supported or not

session_requested() bool[source]

Handle an incoming session request

This method is called when a session open request is received from the client, indicating it wishes to open a channel to be used for running a shell, executing a command, or connecting to a subsystem. If the application wishes to accept the session, it must override this method to return either an SSHServerSession object to use to process the data received on the channel or a tuple consisting of an SSHServerChannel object created with create_server_channel and an SSHServerSession, if the application wishes to pass non-default arguments when creating the channel.

If blocking operations need to be performed before the session can be created, a coroutine which returns an SSHServerSession object can be returned instead of the session iself. This can be either returned directly or as a part of a tuple with an SSHServerChannel object.

To reject this request, this method should return False to send back a “Session refused” response or raise a ChannelOpenError exception with the reason for the failure.

The details of what type of session the client wants to start will be delivered to methods on the SSHServerSession object which is returned, along with other information such as environment variables, terminal type, size, and modes.

By default, all session requests are rejected.

Returns:

One of the following:

  • An SSHServerSession object or a coroutine which returns an SSHServerSession

  • A tuple consisting of an SSHServerChannel and the above

  • A callable or coroutine handler function which takes AsyncSSH stream objects for stdin, stdout, and stderr as arguments

  • A tuple consisting of an SSHServerChannel and the above

  • False to refuse the request

Raises:

ChannelOpenError if the session shouldn’t be accepted

sftp_requested() Type[SFTPServer][source]
validate_password(username: str, password: str) bool[source]

Return whether password is valid for this user

This method should return True if the specified password is a valid password for the user being authenticated. It must be overridden by applications wishing to support password authentication.

If the password provided is valid but expired, this method may raise PasswordChangeRequired to request that the client provide a new password before authentication is allowed to complete. In this case, the application must override change_password() to handle the password change request.

This method may be called multiple times with different passwords provided by the client. Applications may wish to limit the number of attempts which are allowed. This can be done by having password_auth_supported() begin returning False after the maximum number of attempts is exceeded.

If blocking operations need to be performed to determine the validity of the password, this method may be defined as a coroutine.

By default, this method returns False for all passwords.

Parameters:
  • username (str) – The user being authenticated

  • password (str) – The password sent by the client

Returns:

A bool indicating if the specified password is valid for the user being authenticated

Raises:

PasswordChangeRequired if the password provided is expired and needs to be changed

faker_file.tests.sftp_server.start_server(host: str = '0.0.0.0', port: int = 2222) None[source]
async faker_file.tests.sftp_server.start_server_async(host: str = '0.0.0.0', port: int = 2222) None[source]

faker_file.tests.test_augment module

class faker_file.tests.test_augment.TestSolarizeFunction(methodName='runTest')[source]

Bases: TestCase

Test solarize function.

create_rgb_image()[source]

Create a sample RGB image.

create_rgba_image()[source]

Create a sample RGBA image.

test_solarize_rgb()[source]
test_solarize_rgba()[source]

faker_file.tests.test_augment_file_from_dir_provider module

faker_file.tests.test_base module

class faker_file.tests.test_base.StringListTestCase(methodName='runTest')[source]

Bases: TestCase

StringList test case.

test_string_list() None[source]

faker_file.tests.test_cli module

class faker_file.tests.test_cli.TestCLI(methodName='runTest')[source]

Bases: TestCase

CLI tests.

tearDown() None[source]

Hook method for deconstructing the test fixture after testing it.

test_broken_imports() None[source]

Test broken imports.

test_cli
test_cli_error_no_provider() None[source]

Test CLI, no provider given.

test_cli_generate_completion() None[source]

Test CLI, generate-completion.

test_cli_version() None[source]

Test CLI, version.

faker_file.tests.test_data_integrity module

faker_file.tests.test_django_integration module

class faker_file.tests.test_django_integration.DjangoIntegrationTestCase(methodName='runTest')[source]

Bases: TestCase

Django integration test case.

FAKER: Faker
tearDown(*args, **kwargs) None[source]

Hook method for deconstructing the test fixture after testing it.

test_file

faker_file.tests.test_helpers module

class faker_file.tests.test_helpers.HelpersTestCase(methodName='runTest')[source]

Bases: TestCase

Test StringList test case.

test_random_pop() None[source]

Test random_pop.

test_random_pop_empty_list() None[source]

Test random_pop.

faker_file.tests.test_providers module

faker_file.tests.test_registry module

class faker_file.tests.test_registry.RegistryTestCase(methodName='runTest')[source]

Bases: TestCase

Test registry module.

test_clean_up_exceptions()[source]
test_integration() None[source]

Test add.

test_remove_by_string_not_found()[source]
test_remove_exceptions()[source]

faker_file.tests.test_sftp_server module

class faker_file.tests.test_sftp_server.TestSFTPServerWithManager(methodName='runTest')[source]

Bases: IsolatedAsyncioTestCase, __TestSFTPServerMixin

manager: SFTPServerManager
manager_thread: Thread
classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

sftp_host: str = '127.0.0.1'
sftp_pass: str = 'pass'
sftp_port: int = 4616
sftp_user: str = 'foo'
classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

class faker_file.tests.test_sftp_server.TestSFTPServerWithStartServer(methodName='runTest')[source]

Bases: IsolatedAsyncioTestCase, __TestSFTPServerMixin

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

sftp_host: str = '127.0.0.1'
sftp_pass: str = 'pass'
sftp_port: int = 2464
sftp_user: str = 'foo'
classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

class faker_file.tests.test_sftp_server.TestSFTPServerWithStartServerAsync(methodName='runTest')[source]

Bases: IsolatedAsyncioTestCase, __TestSFTPServerMixin

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

sftp_host: str = '127.0.0.1'
sftp_pass: str = 'pass'
sftp_port: int = 2888
sftp_user: str = 'foo'
classmethod tearDownClass()[source]

Hook method for deconstructing the class fixture after running all tests in the class.

faker_file.tests.test_sftp_storage module

class faker_file.tests.test_sftp_storage.TestSFTPStorageTestCase(methodName='runTest')[source]

Bases: TestCase

Test SFTP storage.

classmethod free_port() None[source]

Check if the port is in use and wait until it is free.

static is_port_in_use(host: str, port: int) bool[source]
max_port_retry_limit: int = 10
server_manager: SFTPServerManager
server_thread: Thread
classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

sftp_host: str = '127.0.0.1'
sftp_pass: str = 'pass'
sftp_port: int = 4896
sftp_root_path: str = '/upload'
sftp_user: str = 'foo'
tearDown() None[source]

Hook method for deconstructing the test fixture after testing it.

test_file_system_storage_abspath() None[source]

Test FileSystemStorage abspath.

test_integration() None[source]
test_integration_sub_dir() None[source]
test_storage
test_storage_exists_exceptions() None[source]
test_storage_generate_filename_exceptions
test_storage_initialization_exceptions
test_storage_write_bytes_exceptions() None[source]
test_storage_write_text_exceptions() None[source]

faker_file.tests.test_sqlalchemy_integration module

faker_file.tests.test_storages module

class faker_file.tests.test_storages.TestStoragesTestCase(methodName='runTest')[source]

Bases: TestCase

Test storages.

setUp() None[source]

Hook method for setting up the test fixture before exercising it.

tearDown() None[source]

Hook method for deconstructing the test fixture after testing it.

test_base_storage_exceptions
test_cloud_storage_exceptions
test_file_system_storage_abspath() None[source]

Test FileSystemStorage abspath.

test_pathy_file_system_storage_abspath() None[source]

Test PathyFileSystemStorage abspath.

Test PathyFileSystemStorage unlink.

test_storage
test_storage_generate_filename_exceptions
test_storage_initialization_exceptions

faker_file.tests.texts module

faker_file.tests.utils module

class faker_file.tests.utils.AutoFreePortInt(min_port: int = 2223, max_port: int = 5000, host: str = 'localhost', *args, **kwargs)[source]

Bases: int

Automatically and randomly picks a free port within a specified range.

For instance:

# Random free port between default range 2223 and 5000 port = AutoFreePortInt()

# Random free port between 3000 and 4000 port = AutoFreePortInt(min_port=3000, max_port=4000)

For the rest, it behaves like a normal integer.

For better integration, it’s recommended to cast the value to int, like this:

port = int(AutoFreePortInt())

DEFAULT_MAX_PORT: int = 5000
DEFAULT_MIN_PORT: int = 2223
class faker_file.tests.utils.AutoIncPortInt(*args, **kwargs)[source]

Bases: int

Automatically incremented integer value.

Contains state of issued values. Starts from 2223. Every time initialized, value increases.

Usage example:

port = AutoInt() # 2223 port = AutoInt() # 2224 port = AutoInt() # 2225

For the rest, it behaves like a normal integer.

For better integration, it’s recommended to cast the value to int, like this:

port = int(AutoInt())

Module contents