Beispiel #1
0
    def test_for_local_from_callable(self):
        user_code_config = CodeConfig.from_callable(modify_dataset)

        local_code_config = user_code_config.for_local()
        self.assertIs(user_code_config, local_code_config)
        # CodeConfigs from for_local() shall be able to load callable
        self.assertIs(modify_dataset, local_code_config.get_callable())
Beispiel #2
0
 def test_from_callable(self):
     code_config = CodeConfig.from_callable(
         modify_dataset, callable_params=dict(text='Good bye!'))
     self.assertIsInstance(code_config, CodeConfig)
     self.assertIsNone(code_config.inline_code)
     self.assertIsNone(code_config.file_set, FileSet)
     self.assertIsNone(code_config.callable_ref)
     self.assertIs(modify_dataset, code_config.get_callable())
Beispiel #3
0
    def test_for_service_from_callable(self):
        user_code_config = CodeConfig.from_callable(transform_dataset)

        service_code_config = user_code_config.for_service()
        self.assertIsInstance(service_code_config, CodeConfig)
        self.assertIsInstance(service_code_config.callable_ref, str)
        self.assertIsNone(service_code_config._callable)
        self.assertIsNone(service_code_config.inline_code)
        self.assertIsInstance(service_code_config.file_set, FileSet)
        self.assertTrue(service_code_config.file_set.is_local_zip())
Beispiel #4
0
    def test_to_dict(self):
        d = CodeConfig.from_callable(modify_dataset).to_dict()
        # Shall we raise instead?
        self.assertEqual({}, d)

        d = CodeConfig.from_code(INLINE_CODE,
                                 module_name='user_code').to_dict()
        self.assertEqual(
            {
                'callable_ref': 'user_code:process_dataset',
                'inline_code': INLINE_CODE,
            }, d)

        d = CodeConfig.from_file_set(
            FileSet('github://*****:*****@v0.8.2.dev0', includes='*.py'),
            callable_ref=('test.core.byoa.test_config:'
                          'modify_dataset')).to_dict()
        self.assertIsInstance(d.get('file_set'), dict)
        self.assertEqual(('test.core.byoa.test_config:'
                          'modify_dataset'), d.get('callable_ref'))