Exemplo n.º 1
0
    def test_from_github_release(self):
        code_config = CodeConfig.from_github_archive(
            'dcs4cop', 'xcube-byoa-examples', 'v0.1.0.dev0', '0.1.0.dev0',
            'xcube_byoa_1.processor:process_dataset')

        self.assertIsInstance(code_config, CodeConfig)
        self.assertIsNone(code_config.inline_code)
        self.assertIsInstance(code_config.file_set, FileSet)
        self.assertEqual(
            'https://github.com/dcs4cop/'
            'xcube-byoa-examples/archive/v0.1.0.dev0.zip',
            code_config.file_set.path)
        self.assertEqual('xcube_byoa_1.processor:process_dataset',
                         code_config.callable_ref)
Exemplo n.º 2
0
    def test_for_service_from_github_release(self):
        user_code_config = CodeConfig.from_github_archive(
            gh_org='dcs4cop',
            gh_repo='xcube-byoa-examples',
            gh_tag='v0.1.0.dev0',
            gh_release='0.1.0.dev0',
            callable_ref='xcube_byoa_1.processor:process_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.assertFalse(service_code_config.file_set.is_local_dir())
        self.assertEqual(
            'https://github.com/dcs4cop/'
            'xcube-byoa-examples/archive/v0.1.0.dev0.zip',
            service_code_config.file_set.path)
        self.assertEqual('xcube_byoa_1.processor:process_dataset',
                         service_code_config.callable_ref)
Exemplo n.º 3
0
    def test_for_local_from_github_release(self):
        user_code_config = CodeConfig.from_github_archive(
            gh_org='dcs4cop',
            gh_repo='xcube-byoa-examples',
            gh_tag='v0.1.0.dev0',
            gh_release='0.1.0.dev0',
            callable_ref='xcube_byoa_ex1.processor:process_dataset',
        )

        local_code_config = user_code_config.for_local()
        self.assertIsInstance(local_code_config, CodeConfig)
        self.assertIsInstance(local_code_config.callable_ref, str)
        self.assertIsNone(local_code_config._callable)
        self.assertIsNone(local_code_config.inline_code)
        self.assertIsInstance(local_code_config.file_set, FileSet)
        self.assertTrue(local_code_config.file_set.is_local_dir())
        self.assertRegex(os.path.basename(local_code_config.file_set.path),
                         'xcube-byoa-*.')
        self.assertEqual('xcube_byoa_ex1.processor:process_dataset',
                         local_code_config.callable_ref)
        # CodeConfigs from for_local() shall be able to load callable
        self.assertTrue(callable(local_code_config.get_callable()))