示例#1
0
    def test_update_fromVersion_from_oldFile(self, mocker):
        """
        Given
            - An existing content item that already contains a fromversion key of 6.0.0.
        When
            - Calling set_fromVersion method.
        Then
            - Ensure that the fromVersion key in the file remains 6.0.0.
        """

        mocker.patch.object(BaseUpdate, '__init__', return_value=None)
        base_update = BaseUpdate()
        self.init_BaseUpdate(base_update, oldfile_version=VERSION_6_0_0)
        base_update.set_fromVersion()
        assert base_update.data.get(
            base_update.from_version_key) == VERSION_6_0_0
示例#2
0
 def test_update_fromVersion_default_version_lower_then_general(
         self, mocker):
     """
     Given
         - A new special content item with default fromVersion that is lower than the general.
     When
         - Calling set_fromVersion method.
     Then
         - Ensure that fromVersion key in the file data was set to the general fromVersion.
     """
     mocker.patch.object(BaseUpdate, '__init__', return_value=None)
     base_update = BaseUpdate()
     self.init_BaseUpdate(base_update)
     base_update.set_fromVersion('5.5.0')
     assert base_update.data.get(
         base_update.from_version_key) == GENERAL_DEFAULT_FROMVERSION
示例#3
0
 def test_update_fromVersion_from_default_contentItem_askuser_False(
         self, mocker):
     """
     Given
         - A new content item.
     When
         - Calling set_fromVersion method.
     Then
         - Ensure that fromVersion key in the file data hasn't been generated.
     """
     mocker.patch.object(BaseUpdate, '__init__', return_value=None)
     base_update = BaseUpdate()
     self.init_BaseUpdate(base_update, assume_yes=False)
     mocker.patch.object(BaseUpdate, 'get_answer', return_value='F')
     base_update.set_fromVersion()
     assert base_update.from_version_key not in base_update.data
示例#4
0
    def test_update_fromVersion_from_flag(self, mocker):
        """
        Given
            - A content item without a fromversion key in its current state.
            - The fromversion key to set is specified in the format arguments.
        When
            - Calling set_fromVersion method.
        Then
            - Ensure that fromVersion key in the file data was set to the specific test version.
        """

        mocker.patch.object(BaseUpdate, '__init__', return_value=None)
        base_update = BaseUpdate()
        self.init_BaseUpdate(base_update, VERSION_6_0_0)
        base_update.set_fromVersion()
        assert base_update.data.get(
            base_update.from_version_key) == VERSION_6_0_0
示例#5
0
 def test_update_fromVersion_from_default_contentItem_askuser_True(
         self, mocker):
     """
     Given
         - A new content item.
     When
         - Calling set_fromVersion method.
     Then
         - Ensure that fromVersion key in the file data was set to the GENERAL_DEFAULT_FROMVERSION.
          item version if the user answers Y.
     """
     mocker.patch.object(BaseUpdate, '__init__', return_value=None)
     base_update = BaseUpdate()
     self.init_BaseUpdate(base_update, assume_yes=False)
     mocker.patch.object(BaseUpdate, 'get_answer', return_value='Y')
     base_update.set_fromVersion()
     assert base_update.data.get(
         base_update.from_version_key) == GENERAL_DEFAULT_FROMVERSION
示例#6
0
    def test_update_fromVersion_from_data_with_oldfile(self, mocker):
        """
        Given
            - An existing content item that already contains a fromversion key of 6.1.0.
            - The user manually updated the fromversion key to 6.0.0 in the current version.
        When
            - Calling set_fromVersion method.
        Then
            - Ensure that fromVersion remains 6.0.0.
        """

        mocker.patch.object(BaseUpdate, '__init__', return_value=None)
        base_update = BaseUpdate()
        self.init_BaseUpdate(base_update,
                             oldfile_version='6.1.0',
                             current_fromVersion=VERSION_6_0_0)
        base_update.set_fromVersion()
        assert base_update.data.get(
            base_update.from_version_key) == VERSION_6_0_0
示例#7
0
    def test_update_fromVersion_from_default_contentItem(
            self, mocker, content_type):
        """
        Given
            - A new special content item.
        When
            - Calling set_fromVersion method.
        Then
            - Ensure that fromVersion key in the file data was set to the specific default content item version.
        """
        mocker.patch.object(BaseUpdate, '__init__', return_value=None)
        mocker.patch(
            'demisto_sdk.commands.common.constants.GENERAL_DEFAULT_FROMVERSION',
            return_value='6.2.0')

        base_update = BaseUpdate()
        self.init_BaseUpdate(base_update)
        base_update.set_fromVersion(
            FILETYPE_TO_DEFAULT_FROMVERSION.get(content_type))
        assert base_update.data.get(
            base_update.from_version_key
        ) == FILETYPE_TO_DEFAULT_FROMVERSION.get(content_type)