Exemplo n.º 1
0
    def test_Dna(self):
        # create DNA object
        dna1 = Dna(name="dna1",
                   module_type="neuron",
                   author="kalliope",
                   kalliope_supported_version="0.4.4",
                   tags="test")

        dna2 = Dna(name="dna2",
                   module_type="neuron",
                   author="community",
                   kalliope_supported_version="0.4.2",
                   tags="other")

        # this dna is exactly the same as the first one
        dna3 = Dna(name="dna1",
                   module_type="neuron",
                   author="kalliope",
                   kalliope_supported_version="0.4.4",
                   tags="test")

        expected_result_serialize = {
            'kalliope_supported_version': '0.4.4',
            'tags': 'test',
            'type': 'neuron',
            'name': 'dna1',
            'author': 'kalliope'
        }

        self.assertDictEqual(expected_result_serialize, dna1.serialize())

        self.assertTrue(dna1.__eq__(dna3))
        self.assertFalse(dna1.__eq__(dna2))
Exemplo n.º 2
0
    def test_get_dna(self):

        expected_result = Dna()
        expected_result.name = "neuron_test"
        expected_result.module_type = "neuron"
        expected_result.tags = ['test']
        expected_result.author = 'Kalliope project team'
        expected_result.kalliope_supported_version = [0.4]

        dna_to_test = DnaLoader(self.dna_test_file).get_dna()

        self.assertTrue(dna_to_test.__eq__(expected_result))
Exemplo n.º 3
0
    def _load_dna(self):
        """
        retur a DNA object from a loaded yaml file
        :return:
        """
        new_dna = None
        if self._check_dna_file(self.yaml_config):
            new_dna = Dna()
            new_dna.name = self.yaml_config["name"]
            new_dna.module_type = self.yaml_config["type"]
            new_dna.author = self.yaml_config["author"]
            new_dna.kalliope_supported_version = self.yaml_config["kalliope_supported_version"]
            new_dna.tags = self.yaml_config["tags"]

        return new_dna
Exemplo n.º 4
0
    def test_is_settings_ok(self):
        # -----------------
        # valid resource
        # -----------------
        # valid neuron
        valid_resource = Resources()
        valid_resource.neuron_folder = "/path"
        dna = Dna()
        dna.module_type = "neuron"
        self.assertTrue(ResourcesManager.is_settings_ok(valid_resource, dna))

        # valid stt
        valid_resource = Resources()
        valid_resource.stt_folder = "/path"
        dna = Dna()
        dna.module_type = "stt"
        self.assertTrue(ResourcesManager.is_settings_ok(valid_resource, dna))

        # valid tts
        valid_resource = Resources()
        valid_resource.tts_folder = "/path"
        dna = Dna()
        dna.module_type = "tss"
        self.assertTrue(ResourcesManager.is_settings_ok(valid_resource, dna))

        # valid trigger
        valid_resource = Resources()
        valid_resource.trigger_folder = "/path"
        dna = Dna()
        dna.module_type = "trigger"
        self.assertTrue(ResourcesManager.is_settings_ok(valid_resource, dna))

        # -----------------
        # invalid resource
        # -----------------
        # valid neuron
        valid_resource = Resources()
        valid_resource.neuron_folder = None
        dna = Dna()
        dna.module_type = "neuron"
        self.assertFalse(ResourcesManager.is_settings_ok(valid_resource, dna))

        # valid stt
        valid_resource = Resources()
        valid_resource.stt_folder = None
        dna = Dna()
        dna.module_type = "stt"
        self.assertFalse(ResourcesManager.is_settings_ok(valid_resource, dna))

        # valid tts
        valid_resource = Resources()
        valid_resource.tts_folder = None
        dna = Dna()
        dna.module_type = "tts"
        self.assertFalse(ResourcesManager.is_settings_ok(valid_resource, dna))

        # valid trigger
        valid_resource = Resources()
        valid_resource.trigger_folder = None
        dna = Dna()
        dna.module_type = "trigger"
        self.assertFalse(ResourcesManager.is_settings_ok(valid_resource, dna))