Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Model State tracking #103

Closed
manuGil opened this issue Mar 8, 2023 · 1 comment
Closed

Test: Model State tracking #103

manuGil opened this issue Mar 8, 2023 · 1 comment
Assignees
Labels

Comments

@manuGil
Copy link
Collaborator

manuGil commented Mar 8, 2023

We need to implement tests for the following scenario:

Description

Tests that class ModelState set model variable correctly

Code reference

class ModelState(dict):
'''Dictionary-like object to store model state
Model state variables are mutable by default, but can be set
immutable. In the latter case any actions that set the immutable
model state variable are ignored.

Test Cases

Case 1: The model state should be initialized with a set of immutable variables

  • Preconditions: a variable number of args and kwargs
  • Test Steps:
    • Create an instance of ModelState by passing a number of args and kwargs
  • Expected Result: initialized instance of ModelState with an empty set of immutable variables
  • Postcondition: A instance of ModelState is created

Case 2: Add and update state variable and their values

  • Preconditions: An instance of ModelState has been successfully initialised
  • Test Steps:
    • Initialize an instance of ModelState
    • Add a new variable and value to the set of immutable variables
    • Change the value of the existing mutable state variable
  • Test Data: variable name and value
  • Expected Result: model variable is either added or updated
  • Postcondition: Instance of ModelState contains new state variable or value

Case 3: set existing state variable as mutable

  • Preconditions: An instance of ModelState has been successfully initialised with at least one state variable
  • Test Steps:
    • Initialize an instance of ModelState
    • call set_mutable() to change variable condition in ModelState
    • check if the new variable was added to the set of mutable variables
  • Test Data: name for state variable
  • Expected Result: state variable is added to the mutable set
  • Postcondition: state variable of and instance of ModelState is set to mutable

Case 4: set existing state variable as immutable

  • Preconditions: An instance of ModelState has been successfully initialised, with at least one mutable state variable
  • Test Steps:
    • Initialize an instance of ModelState
    • call set_immutable() to change state variable condition in ModelState
    • check if the variable was removed from the set of mutable variables
  • Test Data: name for muttable state variable
  • Expected Result: state variable is removed from the mutable set
  • Postcondition: state variable of an instance of ModelState is set to immutable
@manuGil manuGil added the test label Mar 8, 2023
@manuGil manuGil self-assigned this Mar 8, 2023
@niketagrawal
Copy link
Collaborator

Fixed with #112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants