EnumLibrary

Robot Framework library documentation

EnumLibrary Documentation

Version 1.0.0 Scope TEST 12 Keywords
Author: Bruce WayneMaintainer: Docs TeamLicense: MITRobot Framework: >=7.0Python: >=3.11
Sample Usage
Robot
*** Settings ***
Library    EnumLibrary

*** Test Cases ***
Example
    [Documentation]    Demonstrates using EnumLibrary
    # add your keyword calls here

Introduction

Sample library demonstrating Enum type usage.

This library demonstrates Enum type support in Robot Framework keywords.

It showcases various Enum patterns including:

  • Enum with default values
  • Enum with different value types (int, str, float)
  • Multiple Enum parameters
  • Mixed Enum and regular parameters

Arguments

level : LogLevel default: INFO
Allowed values 5 options
DEBUG = "debug"
INFO = "info"
WARNING = "warning"
ERROR = "error"
CRITICAL = "critical"

Documentation

Set the logging level.

Arguments:

  • level: Log level (default: INFO)

Returns: None

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    Set Log Level     ${LogLevel.INFO}
    Set Log Level     level=ERROR

Arguments

item : str
status : Status default: PENDING
Allowed values 5 options
PENDING = 1
ACTIVE = 2
COMPLETED = 3
CANCELLED = 4
FAILED = 5
priority : Priority default: MEDIUM
Allowed values 4 options
LOW = 1
MEDIUM = 2
HIGH = 3
URGENT = 4

Return Type

dict

Documentation

Process an item with status and priority.

Arguments:

  • item: Item name or identifier
  • status: Processing status (default: PENDING)
  • priority: Processing priority (default: MEDIUM)

Returns: Dictionary with processing result

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${result}    Process With Status    item-123    status=ACTIVE    priority=HIGH

Arguments

items : List[str]
status : Status
Allowed values 5 options
PENDING = 1
ACTIVE = 2
COMPLETED = 3
CANCELLED = 4
FAILED = 5

Return Type

List[str]

Documentation

Filter items by status.

Arguments:

  • items: List of item identifiers
  • status: Status to filter by

Returns: Filtered list of items matching the status

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${items}    Create List    item1    item2    item3
    ${filtered}    Filter By Status    ${items}    ${Status.ACTIVE}

Arguments

color : Color
Allowed values 5 options
RED = "red"
GREEN = "green"
BLUE = "blue"
YELLOW = "yellow"
PURPLE = "purple"
intensity : Optional[int] default: None

Documentation

Set a color with optional intensity.

Arguments:

  • color: Color to set
  • intensity: Optional intensity value (0-100)

Returns: None

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    Set Color     ${Color.RED}    intensity=75
    Set Color     color=GREEN

Arguments

value : float
from_unit : TemperatureUnit
Allowed values 3 options
CELSIUS = "celsius"
FAHRENHEIT = "fahrenheit"
KELVIN = "kelvin"
to_unit : TemperatureUnit default: CELSIUS
Allowed values 3 options
CELSIUS = "celsius"
FAHRENHEIT = "fahrenheit"
KELVIN = "kelvin"

Return Type

float

Documentation

Convert temperature between units.

Arguments:

  • value: Temperature value
  • from_unit: Source temperature unit
  • to_unit: Target temperature unit (default: CELSIUS)

Returns: Converted temperature value

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${celsius}    Convert Temperature    32    ${TemperatureUnit.FAHRENHEIT}    ${TemperatureUnit.CELSIUS}

Arguments

status : Status
Allowed values 5 options
PENDING = 1
ACTIVE = 2
COMPLETED = 3
CANCELLED = 4
FAILED = 5

Return Type

dict

Documentation

Get information about a status.

Arguments:

  • status: Status to get information for

Returns: Dictionary with status information

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${info}    Get Status Info    ${Status.ACTIVE}

Arguments

name : str
priority : Priority default: MEDIUM
Allowed values 4 options
LOW = 1
MEDIUM = 2
HIGH = 3
URGENT = 4
status : Status default: PENDING
Allowed values 5 options
PENDING = 1
ACTIVE = 2
COMPLETED = 3
CANCELLED = 4
FAILED = 5

Return Type

dict

Documentation

Create a new task with priority and status.

Arguments:

  • name: Task name
  • priority: Task priority (default: MEDIUM)
  • status: Initial status (default: PENDING)

Returns: Dictionary with task information

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${task}    Create Task    Important Task    priority=HIGH    status=PENDING

Arguments

message : str
level : LogLevel default: INFO
Allowed values 5 options
DEBUG = "debug"
INFO = "info"
WARNING = "warning"
ERROR = "error"
CRITICAL = "critical"
color : Optional[Color] default: None

Documentation

Log a message with specified level and optional color.

Arguments:

  • message: Message to log
  • level: Log level (default: INFO)
  • color: Optional color for display

Returns: None

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    Log Message     This is an error    level=ERROR    color=RED
    Log Message     Information message

Return Type

List[str]

Documentation

Get all available status values.

Returns: List of all status names

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${statuses}    Get All Statuses
    Should Contain     ${statuses}    ACTIVE

Return Type

List[str]

Documentation

Get all available priority values.

Returns: List of all priority names

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${priorities}    Get All Priorities
    Should Contain     ${priorities}    HIGH

Arguments

status : Status
Allowed values 5 options
PENDING = 1
ACTIVE = 2
COMPLETED = 3
CANCELLED = 4
FAILED = 5

Return Type

bool

Documentation

Validate if a status is valid.

Arguments:

  • status: Status to validate

Returns: True if status is valid, False otherwise

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${valid}    Validate Status    ${Status.ACTIVE}
    Should Be True     ${valid}

Arguments

value : int

Return Type

Optional[Status]

Documentation

Get status enum by its integer value.

Arguments:

  • value: Status integer value

Returns: Status enum if found, None otherwise

Example:

*** Settings ***
Library    EnumLibrary


*** Test Cases ***
Example Test
    ${status}    Get Status By Value    2
    Should Be Equal     ${status.name}    ACTIVE

Need Help?

Found an issue or have a feature request for this library? Let the maintainers know by opening a new GitHub issue. Please include environment details and relevant log output to help us reproduce the problem.

Open an Issue on GitHub