Skip to main content

robotframework extension lib for test mongodb

Project description


robot framework extension for test connect mongodb

How to Use

pip install robot-mongodb-library

Import into project file : example.robot

*** Settings ***
Library   RobotMongoDBLibrary.Insert
Library   RobotMongoDBLibrary.Update
Library   RobotMongoDBLibrary.Find
Library   RobotMongoDBLibrary.Delete

*** Variables ***
# &{MONGODB_CONNECT_STRING}    host=   port=27017   username=admin   password=password    database=robotdb     collection=customer

&{MONGODB_CONNECT_STRING}=   connection=mongodb://admin:password@,,    database=robotdb   collection=customer

*** Test Cases ***
Test insert data into mongodb
    &{DATA}     Create Dictionary   _id=X100001      name=Tarathep      address=Thailand     phone=8888888888
    ${MSG}      InsertOne   ${MONGODB_CONNECT_STRING}    ${DATA}
    Should Be Equal    ${MSG}    INSERTED SUCCESS

Test find by fillter data from mongodb
    &{FILLTER}     Create Dictionary   name=Tarathep      address=Thailand
    FOR    ${RESULT}    IN    @{RESULTS}
           Log To Console    ${RESULT["phone"]}

Test update data phone into mongodb by ID
    &{NEWDATA}     Create Dictionary        phone=0649359xxx
    ${MSG}      Update   ${MONGODB_CONNECT_STRING}    X100001      ${NEWDATA}
    Should Be Equal    ${MSG}    UPDATED SUCCESS

Test find data by ID from mongodb
    ${RESULTS}     FindOneByID    ${MONGODB_CONNECT_STRING}    X100001
    Log To Console      ${RESULTS}

Test delete data by ID into mongodb
    ${MSG}     DeleteOneByID    ${MONGODB_CONNECT_STRING}    X100001
    Should Be Equal    ${MSG}    DELETED SUCCESS

Example Result

alt text

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robot-mongodb-library-0.0.5.tar.gz (3.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page