コード例 #1
0
    def test_create_classifier_from_old_classifier(self, tmpdir):
        """
        Given:
        - 'old_classifier': Old classifier to convert into 6_0_0 classifier.
        - 'intersection_fields': List of the intersecting fields of classifiers 5_9_9 and below to classifiers 6_0_0.

        When:
        - Creating a 6_0_0 classifier convention from 5_9_9 and below classifier

        Then:
        - Ensure expected classifier is created in the expected path with the expected data.

        """
        fake_pack_name = 'FakeTestPack'
        repo = Repo(tmpdir)
        repo_path = Path(repo.path)
        fake_pack = MockPack(repo_path / 'Packs', fake_pack_name, repo)
        fake_pack.create_classifier('Cymulate_5_9_9',
                                    util_load_json(self.OLD_CLASSIFIER_PATH))
        fake_pack_path = fake_pack.path
        converter = ClassifierSixConverter(Pack(fake_pack_path))
        old_classifier = Classifier(self.OLD_CLASSIFIER_PATH)
        intersecting_fields = converter.get_classifiers_schema_intersection_fields(
        )
        converter.create_classifier_from_old_classifier(
            old_classifier, intersecting_fields)
        classifier_expected_path = f'{tmpdir}/Packs/FakeTestPack/Classifiers/classifier-Cymulate.json'
        self.assert_expected_file_output(classifier_expected_path,
                                         'classifier-Cymulate')
コード例 #2
0
    def test_create_mapper_from_old_classifier(self, tmpdir):
        """
        Given:
        - 'old_classifier': Old classifier to convert into 6_0_0 classifier.

        When:
        - Creating a 6_0_0 mapper convention from 5_9_9 and below classifier

        Then:
        - Ensure expected mapper is created in the expected path with the expected data.

        """
        fake_pack_name = 'FakeTestPack'
        repo = Repo(tmpdir)
        repo_path = Path(repo.path)
        fake_pack = MockPack(repo_path / 'Packs', fake_pack_name, repo)
        fake_pack.create_classifier('Cymulate_5_9_9',
                                    util_load_json(self.OLD_CLASSIFIER_PATH))
        fake_pack_path = fake_pack.path
        converter = ClassifierSixConverter(Pack(fake_pack_path))
        old_classifier = Classifier(self.OLD_CLASSIFIER_PATH)
        converter.create_mapper_from_old_classifier(old_classifier)
        mapper_path = f'{tmpdir}/Packs/FakeTestPack/Classifiers/classifier-mapper-incoming-Cymulate.json'
        self.assert_expected_file_output(
            mapper_path, 'classifier-mapper-incoming-Cymulate')
コード例 #3
0
 def test_convert_dir(self, tmpdir):
     fake_pack_name = 'FakeTestPack'
     repo = Repo(tmpdir)
     repo_path = Path(repo.path)
     fake_pack = MockPack(repo_path / 'Packs', fake_pack_name, repo)
     fake_pack.create_classifier('Cymulate_5_9_9',
                                 util_load_json(self.OLD_CLASSIFIER_PATH))
     fake_pack_path = fake_pack.path
     classifier_converter = ClassifierSixConverter(Pack(fake_pack_path))
     assert classifier_converter.convert_dir() == 0
     expected_new_classifier_path = f'{tmpdir}/Packs/FakeTestPack/Classifiers/classifier-Cymulate.json'
     expected_new_mapper_path = f'{tmpdir}/Packs/FakeTestPack/Classifiers/classifier-mapper-incoming-Cymulate.json'
     self.assert_expected_file_output(expected_new_classifier_path,
                                      'classifier-Cymulate')
     self.assert_expected_file_output(
         expected_new_mapper_path, 'classifier-mapper-incoming-Cymulate')