Module tests

Contents

Module tests#

Utils#

Module with various useful functions for tests.

tests.utils.get_form_errors(text: str) list#
Returns:

errors displayed to users by a form when it is not validated.

tests.utils.load_data_from_form(text: str, form_id: str) dict#

From an html form, return a dictionnary with its data.

Ex: data = utils.load_data_from_form(response.text, "new_price")

Then data can be modified and used as data for a POST request:

data["status"] = int(EventStatus.Cancelled)
response = client.post(f"/collectives/{event.id}/edit", data=data)
Parameters:
  • text (string) – Raw page HTML to extract form from

  • form_id (string) – the html id of the form to extract

Returns:

the content of the form as a dict

Fixtures#

Module for all fixtures.

App#

Creation of fixture app

tests.fixtures.app.app(db_file)#

Session-wide test Flask application.

tests.fixtures.app.db_file()#

Generate a file path for a db file, and delete it after use

tests.fixtures.app.enable_sanctions()#

Enable sanctions in configuration

Events#

Module to create fixture events.

tests.fixtures.event.activity_event(prototype_activity_event)#
Returns:

An event in with “Activity” visibility level

tests.fixtures.event.cancelled_event(prototype_cancelled_event)#
Returns:

A cancelled event

tests.fixtures.event.disabled_paying_event(prototype_disabled_paying_event)#
Returns:

An event in draft status

tests.fixtures.event.draft_event(prototype_draft_event)#
Returns:

An event in draft status

tests.fixtures.event.event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.event1()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event1_with_answers(event1_with_questions)#
Returns:

An event with answered questions

tests.fixtures.event.event1_with_questions(event1_with_reg)#
Returns:

An event with user registrations and associated questions

tests.fixtures.event.event1_with_reg(event1, user1, user2, user3, user4)#
Returns:

The fixture event1, with 4 users registered.

Return type:

collectives.models.event.Event

tests.fixtures.event.event1_with_reg_waiting_list(event1, user1, user2, user3, user4)#
Returns:

The fixture event1, with 4 users registered, and 2 in waiting_list.

Return type:

collectives.models.event.Event

tests.fixtures.event.event2()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event3()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event4()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event5()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event6()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event7()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event8()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event9()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.event.event_in_less_than_x_hours(prototype_event_in_less_than_x_hours)#

Fixture for an event starting in less than 48 hours (parameterized).

tests.fixtures.event.event_in_less_than_x_hours_with_reg(prototype_event_in_less_than_x_hours, user_with_no_warning_badge, user_with_valid_first_warning_badge, user_with_expired_first_warning_badge, user_with_valid_second_warning_badge, user_with_expired_second_warning_badge, user_with_expired_suspended_badge)#

Returns an event in less than 48 hours (parameterized) with registrations for specified users.

tests.fixtures.event.event_with_no_activity_type_in_less_than_x_hours_with_reg(prototype_event_in_less_than_x_hours, user_with_no_warning_badge, user_with_valid_first_warning_badge)#

Returns an event in less than 48 hours (parameterized) with registrations for specified users.

tests.fixtures.event.free_paying_event(prototype_free_paying_event)#
Returns:

An event in draft status

tests.fixtures.event.generate_event(identifier)#

Creates a new fixture event.

Parameters:

identifier (string) – Any string. It will be add to event title

tests.fixtures.event.inject_fixture(name, identifier)#

Inject a new event into fixtures.

Parameters:
  • name (string) – Fixture name

  • identifier (string) – Any string. It will be add to event title

tests.fixtures.event.past_event(prototype_past_event)#
Returns:

A past event

tests.fixtures.event.paying_event(prototype_paying_event)#
Returns:

An event with associated payment_item and prices

tests.fixtures.event.prototype_activity_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_cancelled_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_disabled_paying_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_draft_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_event_in_less_than_x_hours()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_free_paying_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_past_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_paying_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_service_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_tagged_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.prototype_youth_event()#

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.

tests.fixtures.event.service()#

Create a service activity type fixture.

tests.fixtures.event.service_event(prototype_service_event, service)#
Returns:

An event with a service activity type

tests.fixtures.event.tagged_event(prototype_tagged_event)#
Returns:

A tagged event as Handicaf.

tests.fixtures.event.youth_event(prototype_youth_event: Event)#
Returns:

An event in with registration restricted to youths

Client#

Module to create flask client from existing fixture users.

Connection to the application does not use http but a special client available from the app object. See flask documentation.

This client is used to test GET and POST requests. Base client fixture is client()

For some requests, login is required. Thus, some basic fixtures are offered regarding the client role that will be tested. EG: admin_client() or user1_client(). Those client are based on client().

Warning

Please note that Flask app offer ONLY ONE CLIENT. Thus, if you need to switch between roles in the same test, please use only one client fixture and change user using login()

tests.fixtures.client.admin_client(client, admin_user, app)#

Flask client authenticated as admin.

tests.fixtures.client.client(app)#

Raw and unauthenticated flask client.

tests.fixtures.client.client_with_expired_benevole_badge(client, user_with_expired_benevole_badge)#

Flask client authenticated as user with an expired badge.

tests.fixtures.client.client_with_expired_first_warning_badge(client, user_with_expired_first_warning_badge)#

Flask client authenticated as user with an expired first warning badge.

tests.fixtures.client.client_with_expired_second_warning_badge(client, user_with_expired_second_warning_badge)#

Flask client authenticated as user with an expired second warning badge.

tests.fixtures.client.client_with_expired_suspended_badge(client, user_with_expired_suspended_badge)#

Flask client authenticated as user with an expired suspended badge.

tests.fixtures.client.client_with_no_warning_badge(client, user_with_no_warning_badge)#

Flask client authenticated as user with no late unregistration-related warning badge.

tests.fixtures.client.client_with_valid_benevole_badge(client, user_with_valid_benevole_badge)#

Flask client authenticated as user with a valid badge.

tests.fixtures.client.client_with_valid_first_warning_badge(client, user_with_valid_first_warning_badge)#

Flask client authenticated as user with a valid first warning badge.

tests.fixtures.client.client_with_valid_second_warning_badge(client, user_with_valid_second_warning_badge)#

Flask client authenticated as user with a valid second warning badge.

tests.fixtures.client.client_with_valid_suspended_badge(client, user_with_valid_suspended_badge)#

Flask client authenticated as user with a valid suspended badge.

tests.fixtures.client.extranet_user_client(client, extranet_user)#

Flask client authenticated as extranet_user user.

tests.fixtures.client.hotline_client(client, hotline_user)#

Flask client authenticated as hotline.

tests.fixtures.client.leader_client(client, leader_user)#

Flask client authenticated as regular user.

tests.fixtures.client.login(client, user, password='fooBar2+!', deactivate_spam_protection=True)#

Log the client with given user.

If client has already a connected user, the user will be silently logout.

Parameters:
  • client – The test client from the flask app.

  • user (User) – the user that will be login

  • password (string) – The password to use to login user. Default: see tests.fixtures.user.PASSWORD

  • deactivate_spam_protection (bool) – allow to do as much connexion as wanted

Returns:

True if login is succesfull, False if not.

tests.fixtures.client.logout(client)#

Logs out a client

Parameters:

client – The flask app test_client.

Returns:

True if logout is succesfull

Return type:

bool

tests.fixtures.client.supervisor_client(client, supervisor_user)#

Flask client authenticated as Alpinisme activity supervisor.

tests.fixtures.client.user1_client(client, user1)#

Flask client authenticated as regular user.

tests.fixtures.client.user3_client(client, user3)#

Flask client authenticated as regular user.

tests.fixtures.client.youth_client(client, youth_user)#

Flask client authenticated as youth user.

User#

Module to create fixture users.

tests.fixtures.user.PASSWORD = 'fooBar2+!'#

Default test password for non admin users.

Type:

string

tests.fixtures.user.USER_NAMES = [('Jan', 'Johnston'), ('Evan', 'Walsh'), ('Kimberly', 'Paterson'), ('Jake', 'Marshall'), ('Boris', 'Bailey'), ('Frank', 'Morgan'), ('Chloe', 'White'), ('Michael', 'Davidson'), ('Theresa', 'Bailey'), ('Jake', 'Piper')]#

Basic list of names.

Type:

list()

tests.fixtures.user.add_badge_to_user(user: User, badge_id: int, level: int = 1, expiration_date: date | None = datetime.date(2027, 2, 23), activity_name: str | None = 'Alpinisme', grantor: User | None = None) Badge#

Adds a badge to a user and returns it

Parameters:
  • user – the user to add a badge to

  • expiration_date – the expiration date of the badge (Default is today + 1 year, so a valid one)

  • badge_id – the type of badge to add

  • activity_name – The activity name for the role. Default Alpinisme

  • grantor – The user who granted this badge

tests.fixtures.user.add_benevole_badge_to_user(user, expiration_date=datetime.date(2027, 2, 23), badge_id=1, activity_name='Alpinisme')#

Manage to add a badge to a user

Parameters:
  • user (User) – the user to add a badge to

  • badge_id (badgeIds) – the type of badge to add

  • activity_name (string) – The activity name for the role. Default Alpinisme

Expiration_date:

the expiration date of the badge (Default is today + 1 year, so a valid one)

tests.fixtures.user.admin_user(app)#
Returns:

The admin user.

tests.fixtures.user.extranet_user(prototype_extranet_user)#
Returns:

A user with type extranet.

tests.fixtures.user.generate_user(names)#

Generate fixture users.

Parameters:
  • id (int) – An identifiying integer for the user

  • names ((string,string)) – first and last names for the user

Returns:

the newly created user

Return type:

collectives.models.user.User

tests.fixtures.user.hotline_user(prototype_hotline_user)#
Returns:

A user with a hotline role.

tests.fixtures.user.inject_fixture(name, names)#

Create and add a new fixture user.

Parameters:
  • name (string) – Fixture name.

  • names ("(string,string)") – First and lastname of the user.

tests.fixtures.user.leader2_user(prototype_leader2_user)#
Returns:

An Alpinisme leader user.

tests.fixtures.user.leader2_user_with_event(leader2_user, event2)#
Returns:

A leader User which leads event2

tests.fixtures.user.leader_user(prototype_leader_user)#
Returns:

An Alpinisme leader user.

tests.fixtures.user.leader_user_with_event(leader_user, event1)#
Returns:

A leader User which leads event1

tests.fixtures.user.minor_user(prototype_minor_user: User)#
Returns:

A user with a minor license.

tests.fixtures.user.president_user(prototype_president_user)#
Returns:

A user with a president role.

tests.fixtures.user.promote_to_leader(user, activity='Alpinisme')#

Add a leader role to a user.

Parameters:
  • user (User) – the user to be promoted

  • activity (string) – Activity name to which user will be promoted. Defaul Alpinisme

tests.fixtures.user.promote_user(user, role_id, activity_name='Alpinisme', confidentiality_agreement_signature=True)#

Manage to add a role to a user

Parameters:
  • user (User) – the user to promote

  • role_id (RoleIds) – the type of user to add

  • activity_name (string) – The activity name for the role. Default Alpinisme

  • confidentiality_agreement_signature (bool) – If method should sign the confidentiality agreement for the user.

tests.fixtures.user.prototype_extranet_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_hotline_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_leader2_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_leader_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_minor_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_president_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_supervisor_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user101()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_expired_benevole_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_expired_first_warning_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_expired_second_warning_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_expired_suspended_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_practitioner_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_skill_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_valid_benevole_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_valid_first_warning_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_valid_second_warning_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_user_with_valid_suspended_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.prototype_youth_user()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.supervisor_user(prototype_supervisor_user)#
Returns:

A user with an Alpinisme supervisor role.

tests.fixtures.user.user1()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user10()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user101_same_email(prototype_user101, user1)#
Returns:

Another user with the same email as user1

tests.fixtures.user.user2()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user3()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user4()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user5()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user6()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user7()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user8()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user9()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user_with_expired_benevole_badge(prototype_user_with_expired_benevole_badge: User)#
Returns:

A user with an expired benevole Badge.

tests.fixtures.user.user_with_expired_first_warning_badge(prototype_user_with_expired_first_warning_badge: User, enable_sanctions)#
Returns:

A user with an expired first warning Badge.

tests.fixtures.user.user_with_expired_second_warning_badge(prototype_user_with_expired_second_warning_badge: User, enable_sanctions)#
Returns:

A user with an expired second warning Badge.

tests.fixtures.user.user_with_expired_suspended_badge(prototype_user_with_expired_suspended_badge: User, enable_sanctions)#
Returns:

A user with an expired suspended Badge.

tests.fixtures.user.user_with_no_warning_badge()#

int([x]) -> integer int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating-point numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4

tests.fixtures.user.user_with_practitioner_badge(prototype_user_with_practitioner_badge: User, leader_user: User)#
Returns:

A user with a practitioner Badge.

tests.fixtures.user.user_with_skill_badge(prototype_user_with_skill_badge: User, leader_user: User, custom_skill: BadgeCustomLevel)#
Returns:

A user with a skill Badge.

tests.fixtures.user.user_with_valid_benevole_badge(prototype_user_with_valid_benevole_badge: User)#
Returns:

A user with a valid benevole Badge.

tests.fixtures.user.user_with_valid_first_warning_badge(prototype_user_with_valid_first_warning_badge: User, enable_sanctions)#
Returns:

A user with a valid first warning Badge.

tests.fixtures.user.user_with_valid_second_warning_badge(prototype_user_with_valid_second_warning_badge: User, enable_sanctions)#
Returns:

A user with a valid second warning Badge.

tests.fixtures.user.user_with_valid_suspended_badge(prototype_user_with_valid_suspended_badge: User, enable_sanctions)#
Returns:

A user with a valid suspended Badge.

tests.fixtures.user.youth_user(prototype_youth_user: User)#
Returns:

A user with a youth license.

Mocking ressources#

Mock module for better tests.#

Mocks are build to test without the need of outside ressources such as extranet ou payment website. To mock it, monkeypatch (see doc <https://docs.pytest.org/en/7.1.x/how-to/monkeypatch.html>_) is used. It exchanges a function, a method or a class by another one from this module.

Unit tests#

Unit tests modules#

Basic unit tests for an application module. This module architecture mimics the collectives one, eg, collectives.utils.test_extranet functions are tested by tests.unit.utils.test_extranet.