예제 #1
0
    def create_attributes (self, number, name, type, value):
        """
        create attributes to Notifications
        :param number: number of attributes
        :param name: prefix to attribute name. ex: temperature --> temperature_0
        :param type: attributes type
        :param value: attributes value or in same cases could you use random values ( random (alphanumeric with 4 characters only) | random alphanumeric | random number)
        :return attributes list
        """
        self.attrs = []
        self.attributes_number = number
        if name == RANDOM:
            self.attributes_name = 'name_' + general_utils.string_generator(4)
        else:
            self.attributes_name = name
        if type == RANDOM:
            self.attribute_type = 'type_' + general_utils.string_generator(4)
        else:
            self.attribute_type = type

        if value == RANDOM:
            self.attributes_value = general_utils.string_generator(4)
        elif value.find(RANDOM_ALPHANUMERIC) >= 0:
            length = int(value.split("=")[1])
            self.attributes_value = general_utils.string_generator(length)
        elif value.find(RANDOM_NUMBER) >= 0:
            length = int(value.split("=")[1])
            self.attributes_value = general_utils.number_generator(length)
        else:
            self.attributes_value = value
        self.attributes_value = str(self.attributes_value)
        for i in range(0,int(self.attributes_number)):
            self.attrs.append(self.__append_attribute(self.attributes_name+"_"+str(i), self.attribute_type, self.attributes_value, self.metadatas))
        return self.attrs
예제 #2
0
 def __new_metadata(self, name, type, value):
     """
      create a metadata
     :param name: metadata name (OPTIONAL: random)
     :param type: metadata type (OPTIONAL: random)
     :param value: metadata value (OPTIONAL: random)
     :return: metadata dictionary
     """
     if name == RANDOM:
         name = 'name_' + general_utils.string_generator(4)
     if type == RANDOM:
         type = 'type_' + general_utils.string_generator(4)
     if value == RANDOM:
         value = general_utils.string_generator(4)
     return {NAME: name, TYPE: type, VALUE: value}
예제 #3
0
 def __new_metadata(self, name, type, value):
     """
      create a metadata
     :param name: metadata name (OPTIONAL: random)
     :param type: metadata type (OPTIONAL: random)
     :param value: metadata value (OPTIONAL: random)
     :return: metadata dictionary
     """
     if name == RANDOM:
         name = 'name_' + general_utils.string_generator(4)
     if type == RANDOM:
         type = 'type_' + general_utils.string_generator(4)
     if value == RANDOM:
         value = general_utils.string_generator(4)
     return {NAME: name, TYPE: type, VALUE: value}
예제 #4
0
    def create_attributes(self, number, name, type, value):
        """
        create attributes to Notifications
        :param number: number of attributes
        :param name: prefix to attribute name. ex: temperature --> temperature_0
        :param type: attributes type
        :param value: attributes value or in same cases could you use random values ( random (alphanumeric with 4 characters only) | random alphanumeric | random number)
        :return attributes list
        """
        self.attrs = []
        self.attributes_number = number
        if name == RANDOM:
            self.attributes_name = 'name_' + general_utils.string_generator(4)
        else:
            self.attributes_name = name
        if type == RANDOM:
            self.attribute_type = 'type_' + general_utils.string_generator(4)
        else:
            self.attribute_type = type

        if value == RANDOM:
            self.attributes_value = general_utils.string_generator(4)
        elif value.find(RANDOM_ALPHANUMERIC) >= 0:
            length = int(value.split("=")[1])
            self.attributes_value = general_utils.string_generator(length)
        elif value.find(RANDOM_NUMBER) >= 0:
            length = int(value.split("=")[1])
            self.attributes_value = general_utils.number_generator(length)
        else:
            self.attributes_value = value
        self.attributes_value = str(self.attributes_value)
        for i in range(0, int(self.attributes_number)):
            self.attrs.append(
                self.__append_attribute(self.attributes_name + "_" + str(i),
                                        self.attribute_type,
                                        self.attributes_value, self.metadatas))
        return self.attrs