예제 #1
0
    def test_variables_delete_by_resource_id_variable_not_found(self):
        existing_variables = {
            "key1": "value1",
            "key2": "value2",
            "key3": "value3",
        }

        delete_variables = [
            "key4",
        ]

        result_variables = deepcopy(existing_variables)

        resource_id = self.setup_resource(existing_variables)

        test = dbapi.variables_delete_by_resource_id(
            context=self.context,
            resources=self.resources_type,
            resource_id=resource_id,
            data=delete_variables)

        self.assertEqual(resource_id, test.id)
        self.assertEqual(result_variables, test.variables)

        validate = dbapi.resource_get_by_id(self.context, self.resources_type,
                                            resource_id)

        self.assertEqual(resource_id, validate.id)
        self.assertEqual(result_variables, validate.variables)
예제 #2
0
    def test_variables_update_by_resource_id_modify_existing(self):
        existing_variables = {
            "key1": "value1",
            "key2": "value2",
            "key3": "value3",
        }

        update_variables = {
            "key3": "newvalue3",
            "key4": "value4",
        }

        result_variables = deepcopy(existing_variables)
        result_variables.update(deepcopy(update_variables))

        resource_id = self.setup_resource(existing_variables)

        test = dbapi.variables_update_by_resource_id(
            context=self.context,
            resources=self.resources_type,
            resource_id=resource_id,
            data=deepcopy(update_variables))

        self.assertEqual(resource_id, test.id)
        self.assertEqual(result_variables, test.variables)

        validate = dbapi.resource_get_by_id(self.context, self.resources_type,
                                            resource_id)

        self.assertEqual(resource_id, validate.id)
        self.assertEqual(result_variables, validate.variables)
예제 #3
0
    def test_get_resource_by_id_with_variables(self):
        variables = {
            "key1": "value1",
            "key2": "value2",
            "key3": "value3",
        }

        resource_id = self.setup_resource(deepcopy(variables))

        test = dbapi.resource_get_by_id(self.context, self.resources_type,
                                        resource_id)

        self.assertEqual(resource_id, test.id)
        self.assertEqual(variables, test.variables)
예제 #4
0
    def test_variables_update_by_resource_id_existing_empty(self):
        existing_variables = {}

        resource_id = self.setup_resource(existing_variables)

        variables = {
            "key1": "value1",
            "key2": "value2",
            "key3": "value3",
        }

        test = dbapi.variables_update_by_resource_id(self.context,
                                                     self.resources_type,
                                                     resource_id,
                                                     deepcopy(variables))

        self.assertEqual(resource_id, test.id)
        self.assertEqual(variables, test.variables)

        validate = dbapi.resource_get_by_id(self.context, self.resources_type,
                                            resource_id)

        self.assertEqual(resource_id, validate.id)
        self.assertEqual(variables, validate.variables)