示例#1
0
class A_Variables_class:

    def setup_method(self, method):

        rest_variables = """[
                      {
                        "name" : "doubleTaskVar",
                        "scope" : "local",
                        "type" : "double",
                        "value" : 99.99
                      },
                      {
                        "name" : "stringProcVar",
                        "scope" : "global",
                        "type" : "string",
                        "value" : "This is a ProcVariable"
                      }
                    ]"""
        self.rest_variables = json.loads(rest_variables)
        self.variables = Variables(rest_data=self.rest_variables)

    def should_load_rest_data(self):
        assert hasattr(self.variables, "rest_data")

        # Local variables has a underscore at end of variable name
        assert self.variables["doubleTaskVar_"] == 99.99
        assert self.variables["stringProcVar"] == "This is a ProcVariable"
        assert len(self.variables) == 2
        assert self.rest_variables == self.variables.rest_data

    def should_sync_new_variables(self):

        self.variables["newVariable"] = "content"
        self.variables["localVariable_"] = 123

        rest_result = self.variables.sync_rest()
        assert len(rest_result) == 2
        for variable in rest_result:
            if variable["name"] == "newVariable":
                assert variable["scope"] == "global"
            else:
                assert variable["scope"] == "local"
                assert variable["name"] == "localVariable"

    def should_sync_updated_variables(self):
        self.variables["stringProcVar"] = "new variable content"
        rest_result = self.variables.sync_rest()

        assert len(rest_result) == 1
        assert rest_result[0]["name"] == "stringProcVar"
        assert rest_result[0]["value"] == "new variable content"
示例#2
0
    def setup_method(self, method):

        rest_variables = """[
                      {
                        "name" : "doubleTaskVar",
                        "scope" : "local",
                        "type" : "double",
                        "value" : 99.99
                      },
                      {
                        "name" : "stringProcVar",
                        "scope" : "global",
                        "type" : "string",
                        "value" : "This is a ProcVariable"
                      }
                    ]"""
        self.rest_variables = json.loads(rest_variables)
        self.variables = Variables(rest_data=self.rest_variables)