Example #1
0
    def test_Neuron(self):

        neuron1 = Neuron(name="test",
                         parameters={
                             "key1": "val1",
                             "key2": "val2"
                         })
        neuron2 = Neuron(name="test",
                         parameters={
                             "key3": "val3",
                             "key4": "val4"
                         })
        neuron3 = Neuron(name="test",
                         parameters={
                             "key1": "val1",
                             "key2": "val2"
                         })

        expected_result_serialize = {
            'name': 'test',
            'parameters': {
                'key2': 'val2',
                'key1': 'val1'
            }
        }

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

        self.assertTrue(neuron1.__eq__(neuron3))
        self.assertFalse(neuron1.__eq__(neuron2))

        # test password
        neuron_name = "test"
        neuron_parameters = {"password": "******", "parameter": "test"}

        neuron = Neuron()
        neuron.name = neuron_name
        neuron.parameters = neuron_parameters

        expected_result_str = "{'name': 'test', 'parameters': {'password': '******', 'parameter': 'test'}}"

        self.assertDictEqual(ast.literal_eval(neuron.__str__()),
                             ast.literal_eval(expected_result_str))

        neuron_name = "test"
        neuron_parameters = {
            "password_parameter": "my secret",
            "parameter": "test"
        }

        neuron = Neuron()
        neuron.name = neuron_name
        neuron.parameters = neuron_parameters

        expected_result_str = "{'name': 'test', 'parameters': {'parameter': 'test', 'password_parameter': '*****'}}"

        self.assertDictEqual(ast.literal_eval(neuron.__str__()),
                             ast.literal_eval(expected_result_str))
Example #2
0
    def test_password_parameter(self):
        neuron_name = "test"
        neuron_parameters = {"password": "******", "parameter": "test"}

        neuron = Neuron()
        neuron.name = neuron_name
        neuron.parameters = neuron_parameters

        expected_result = "Neuron: name: test, parameters: {'password': '******', 'parameter': 'test'}"

        self.assertEqual(neuron.__str__(), expected_result)
Example #3
0
    def test_Neuron(self):

        neuron1 = Neuron(name="test", parameters={"key1": "val1", "key2": "val2"})
        neuron2 = Neuron(name="test", parameters={"key3": "val3", "key4": "val4"})
        neuron3 = Neuron(name="test", parameters={"key1": "val1", "key2": "val2"})

        expected_result_serialize = {'name': 'test', 'parameters': {'key2': 'val2', 'key1': 'val1'}}

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

        self.assertTrue(neuron1.__eq__(neuron3))
        self.assertFalse(neuron1.__eq__(neuron2))

        # test password
        neuron_name = "test"
        neuron_parameters = {
            "password": "******",
            "parameter": "test"
        }

        neuron = Neuron()
        neuron.name = neuron_name
        neuron.parameters = neuron_parameters

        expected_result_str = "{'name': 'test', 'parameters': {'password': '******', 'parameter': 'test'}}"

        self.assertDictEqual(ast.literal_eval(neuron.__str__()), ast.literal_eval(expected_result_str))

        neuron_name = "test"
        neuron_parameters = {
            "password_parameter": "my secret",
            "parameter": "test"
        }

        neuron = Neuron()
        neuron.name = neuron_name
        neuron.parameters = neuron_parameters

        expected_result_str = "{'name': 'test', 'parameters': {'parameter': 'test', 'password_parameter': '*****'}}"

        self.assertDictEqual(ast.literal_eval(neuron.__str__()), ast.literal_eval(expected_result_str))