def test_is_valid_display_configuration(self, configuration_setting,
                                         answer):
     current = {"configuration": configuration_setting}
     structure = mock_structure("", current)
     validator = IntegrationValidator(structure)
     validator.current_file = current
     assert validator.is_not_valid_display_configuration() is not answer
Exemple #2
0
    def test_is_valid_default_argument(self, current, answer):
        """
        Given: Integration command with arguments.

        When: running is_valid_default_argument command.

        Then: Validate that up to 1 default arg name yields True, else yields False.
        """
        current = {"script": {"commands": current}}
        structure = mock_structure("", current)
        validator = IntegrationValidator(structure)
        validator.current_file = current
        assert validator.is_valid_default_argument() is answer
Exemple #3
0
    def test_is_there_a_runnable_negative(self):
        """
        Given: an integration with no runnable param

        When: running validate on integration with no one of commands, fetch, feed or long-running

        Then: Validate it's invalid.
        """
        current = {"script": {}}
        structure = mock_structure("", current)
        validator = IntegrationValidator(structure)
        validator.current_file = current
        assert validator.is_there_a_runnable() is False
Exemple #4
0
    def test_is_there_a_runnable(self, param):
        """
        Given: one of any runnable integration

        When: running validate on integration with at least one of commands, fetch, feed or long-running

        Then: Validate it's valid.
        """
        current = {"script": param}
        structure = mock_structure("", current)
        validator = IntegrationValidator(structure)
        validator.current_file = current
        assert validator.is_there_a_runnable() is True
    def test_empty_commands(self):
        """
        Given: an integration with no commands

        When: running validate on integration with no command.

        Then: Validate it's valid.
        """
        current = {"script": {"commands": None}}
        structure = mock_structure("", current)
        validator = IntegrationValidator(structure)
        validator.current_file = current
        assert validator.is_valid_default_arguments() is True
 def test_is_outputs_for_reputations_commands_valid(self, current, name,
                                                    answer):
     current = {
         "script": {
             "commands": [{
                 "name": name,
                 "outputs": current
             }]
         }
     }
     structure = mock_structure("", current)
     validator = IntegrationValidator(structure)
     validator.current_file = current
     assert validator.is_outputs_for_reputations_commands_valid() is answer
Exemple #7
0
    def test_is_valid_deprecated_integration(self, current, answer):
        """
        Given
            - A deprecated integration with a display and description.

        When
            - running is_valid_as_deprecated.

        Then
            - an integration with an invalid display name or invalid description will be errored.
        """
        structure = mock_structure("", current)
        validator = IntegrationValidator(structure)
        validator.current_file = current
        assert validator.is_valid_as_deprecated() is answer
Exemple #8
0
    def test_is_context_change_in_readme(self, readme, current_yml, expected):
        """
        Given: a changed YML file

        When: running validate on integration with at least one command

        Then: Validate it's synced with the README.
        """
        patcher = patch('os.path.exists')
        mock_thing = patcher.start()
        mock_thing.side_effect = lambda x: True
        with patch("builtins.open", mock_open(read_data=readme)) as _:
            current = {"script": {}}
            structure = mock_structure("Pack/Test", current)
            validator = IntegrationValidator(structure)
            validator.current_file = current_yml
            res = validator.is_context_change_in_readme()
            assert res == expected
        patcher.stop()
 def test_is_valid_display_name(self, current, answer):
     structure = mock_structure("", current)
     validator = IntegrationValidator(structure)
     validator.current_file = current
     assert validator.is_valid_display_name() is answer
 def test_is_insecure_configured_correctly(self, current, answer):
     current = {"configuration": current}
     structure = mock_structure("", current)
     validator = IntegrationValidator(structure)
     validator.current_file = current
     assert validator.is_insecure_configured_correctly() is answer
 def test_is_valid_beta_integration(self, current, old, answer):
     structure = mock_structure("", current, old)
     validator = IntegrationValidator(structure)
     validator.current_file = current
     validator.old_file = old
     assert validator.is_valid_beta_integration() is answer
 def test_is_valid_default_arguments(self, current, answer):
     current = {"script": {"commands": current}}
     structure = mock_structure("", current)
     validator = IntegrationValidator(structure)
     validator.current_file = current
     assert validator.is_valid_default_arguments() is answer