mercredi 22 mai 2019

Can we write test cases for AWS in hierarchical functions in Python?

I want to write test cases for my current project. For test cases, I am using moto library. I have the following structure in python code.

fun_one()
fun_two()
fun_three()

def main():
    fun_one()
    fun_two()
    fun_three()

    ''''
    # above code can be as dependency in other functions,
    fun_three(fun_two(fun_one()))
    ''''

In above code, functions are using AWS libraries like S3 bucket, DynamoDb, SES, SNS and others. Scripts are running in EC2 Instance.

While writing test cases. I am running scripts locally. I am mocking S3 bucket, DynamoDb Instances and the databases/files in it.

I can write test cases for separate functions. Eg, test cases for fun_one() and others, it works fine. My query is,

Can I write the test case for main() so that whole functions inside that can run using test libraries?

Please guide me with the links to write best test code in Python using AWS services.

Aucun commentaire:

Enregistrer un commentaire