Esempio n. 1
0
    def test_convert_load(self):
        """
        Test that the convert method returns the loaded entry point if load=True at construction time of parameter
        """
        param = PluginParamType(group=('transports', 'data'), load=True)
        entry_point_ssh = get_entry_point_from_string('aiida.transports:ssh')
        entry_point_structure = get_entry_point_from_string(
            'aiida.data:structure')

        entry_point = param.convert('aiida.transports:ssh', None, None)
        self.assertTrue(entry_point, entry_point_ssh)

        entry_point = param.convert('transports:ssh', None, None)
        self.assertTrue(entry_point, entry_point_ssh)

        entry_point = param.convert('ssh', None, None)
        self.assertTrue(entry_point, entry_point_ssh)

        entry_point = param.convert('aiida.data:structure', None, None)
        self.assertTrue(entry_point, entry_point_structure)

        entry_point = param.convert('data:structure', None, None)
        self.assertTrue(entry_point, entry_point_structure)

        entry_point = param.convert('structure', None, None)
        self.assertTrue(entry_point, entry_point_structure)

        with self.assertRaises(click.BadParameter):
            param.convert('not_existent', None, None)
Esempio n. 2
0
    def test_convert(self):
        """
        Test that the convert method returns the correct entry point
        """
        param = PluginParamType(group=('transports', 'data'))

        entry_point = param.convert('aiida.transports:ssh', None, None)
        self.assertEqual(entry_point.name, 'ssh')
        # self.assertTrue(isinstance(entry_point, EntryPoint))

        entry_point = param.convert('transports:ssh', None, None)
        self.assertEqual(entry_point.name, 'ssh')
        # self.assertTrue(isinstance(entry_point, EntryPoint))

        entry_point = param.convert('ssh', None, None)
        self.assertEqual(entry_point.name, 'ssh')
        # self.assertTrue(isinstance(entry_point, EntryPoint))

        entry_point = param.convert('aiida.data:structure', None, None)
        self.assertEqual(entry_point.name, 'structure')
        # self.assertTrue(isinstance(entry_point, EntryPoint))

        entry_point = param.convert('data:structure', None, None)
        self.assertEqual(entry_point.name, 'structure')
        # self.assertTrue(isinstance(entry_point, EntryPoint))

        entry_point = param.convert('structure', None, None)
        self.assertEqual(entry_point.name, 'structure')
        # self.assertTrue(isinstance(entry_point, EntryPoint))

        with self.assertRaises(click.BadParameter):
            param.convert('not_existent', None, None)