"""Tests for malware-uncertainty.core.feature"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from absl.testing import absltest
from absl.testing import parameterized

import numpy as np

from core.feature import feature_type_scope_dict
from config import config


class MyTestCase(parameterized.TestCase):
    @parameterized.named_parameters(
        [("%s" % mtd_name,) + (mtd_name,) for mtd_name in [feature_type_scope_dict['apiseq']]])
    def test_feature_extraction(self, feature_type):
        malware_dir_name = config.get('drebin', 'malware_dir')
        benware_dir_name = config.get('drebin', 'benware_dir')
        meta_data_saving_dir = config.get('drebin', 'intermediate_directory')
        naive_data_saving_dir = config.get('metadata', 'naive_data_pool')
        feature_extractor = feature_type(naive_data_saving_dir, meta_data_saving_dir, update=False)
        malware_features = feature_extractor.feature_extraction(malware_dir_name)
        benign_features = feature_extractor.feature_extraction(benware_dir_name)
        features = malware_features + benign_features
        gt_labels = np.zeros((len(malware_features) + len(benign_features)), dtype=np.int32)
        gt_labels[:len(malware_features)] = 1
        feature_extractor.feature_preprocess(features, gt_labels)
        feature_extractor.feature2ipt(features)


if __name__ == '__main__':
    absltest.main()
