Пример #1
0
 def _validate_entries(self, entries, index_file):
     s = index_ci_state.State()
     for e in entries:
         if CheckKeys.STATE not in e:
             e[CheckKeys.STATE] = s
         if not schema_validation.UniqueEntryValidator(
                 e, index_file).validate().success:
             return False
     return True
 def test_01_succeeds_valid_git_url_git_branch_with_clone_request(self):
     self.assertTrue(
         value_validation.GitCloneValidator(
             {
                 CheckKeys.CLONE: True,
                 FieldKeys.GIT_URL:
                 "https://github.com/bamachrn/cccp-python.git",
                 FieldKeys.GIT_BRANCH: "master",
                 CheckKeys.STATE: index_ci_state.State()
             }, DUMMY_INDEX_FILE).validate().success)
 def test_02_fails_invalid_git_url_valid_git_branch_with_clone_request(
         self):
     self.assertFalse(
         value_validation.GitCloneValidator(
             {
                 CheckKeys.CLONE: True,
                 FieldKeys.GIT_URL:
                 "https://github.com/bamachrn/does-not-exist.git",
                 FieldKeys.GIT_BRANCH: "master",
                 CheckKeys.STATE: index_ci_state.State()
             }, DUMMY_INDEX_FILE).validate().success)
Пример #4
0
    def __init__(self,
                 schema_validators=None,
                 value_validators=None,
                 index_location="./",
                 verbose=True,
                 skip_schema=False,
                 skip_value=False,
                 the_state=None):
        """
        Initializes the test engine
        """
        self.verbose = verbose
        self.skip_schema = skip_schema
        self.skip_value = skip_value

        if self.skip_schema and self.skip_value:
            raise Exception("Cannot skip through all tests")

        # Index file location needs to be provided
        if not path.exists(index_location):
            raise Exception("Could not find location specified for index.")

        # Goto the index location and collect the index files
        self.index_location = path.abspath(index_location)
        self.index_d = path.join(self.index_location, "index.d")
        self.index_files = glob(str.format("{}/*.y*ml", self.index_d))

        if (len(self.index_files) == 0 or
            ((len(self.index_files) == 1) and any("index_template" in s
                                                  for s in self.index_files))):
            raise Exception("No index files to process.")

        # Collect the validators that need to run.
        self.validators = []
        # - Schema Validators:
        if (not (schema_validators and isinstance(schema_validators, list))
                or len(schema_validators) <= 0):
            v_list = config.schema_validators
        else:
            v_list = schema_validators
        if not self.skip_schema:
            self._load_validators(schema_validation, v_list)

        # - Value Validators
        if (not (value_validators and isinstance(value_validators, list))
                or len(value_validators) <= 0):
            v_list = config.value_validators
        else:
            v_list = value_validators
        if not self.skip_value:
            self._load_validators(value_validation, v_list)

        self.summary = {}
        self.state = the_state if the_state else state.State()
Пример #5
0
 def setup_mock_location(self, file_names):
     s = index_ci_state.State()
     mock_loc = path.join(s.state_mock, str(uuid4()))
     if not path.exists(mock_loc):
         mkdir(mock_loc)
     for f, d in file_names.iteritems():
         p = path.join(mock_loc, f)
         if not d:
             with open(p, "a"):
                 utime(p, None)
         else:
             with open(p, "w+") as fl:
                 fl.write(d)
     return s, mock_loc
Пример #6
0
 def setup_mock_location(self, file_names):
     s = index_ci_state.State()
     mock_loc = path.join(s.state_mock, str(uuid4()))
     mock_indexd_location = path.join(mock_loc, "index.d")
     if not path.exists(mock_loc):
         mkdir(mock_loc)
     if not path.exists(mock_indexd_location):
         mkdir(mock_indexd_location)
     for f, d in file_names.iteritems():
         p = path.join(mock_indexd_location, f)
         if not d:
             with open(p, "a"):
                 utime(p, None)
         else:
             dump_yaml(p, d)
     return s, mock_loc