Exemple #1
0
    def entry_point_class_list(self, fixture):
        """EntryPointClassList is a special ConfigSetting which reads its value from a pkg_resources
           entry point which contains a list of classes published by any (possibly other) egg."""
        # Because we cannot remove EasterEggs from pkg_resources, the next test must happen after
        # this one. The next check just ensures that we know when that does not happen:
        with expected(pkg_resources.DistributionNotFound):
            pkg_resources.require('test-inject')

        fixture.set_config_spec(
            easter_egg,
            'reahl.component_dev.test_config:ConfigWithEntryPointClassList')

        # Publish some classes on the entry point being tested
        line = 'ListedClass1 = reahl.component_dev.test_config:ListedClass1'
        easter_egg.add_entry_point_from_line('some.test.entrypoint', line)
        line = 'ListedClass2 = reahl.component_dev.test_config:ListedClass2'
        easter_egg.add_entry_point_from_line('some.test.entrypoint', line)

        # Usually this happens inside other infrastructure, such as the implementation of reahl serve (see reahl-dev)
        config = StoredConfiguration(fixture.config_dir.name)
        config.configure()

        # The classes are found from the entry point
        vassert(
            set(config.some_key.some_setting) == {ListedClass1, ListedClass2})
Exemple #2
0
def test_interface_with_meta_info():
    """A Reahl component can publish a ReahlEgg instance to supply extra meta information about itself.
       Such interfaces with extra information are also often used from a flattened list in dependency order."""

    easter_egg.clear()
    easter_egg.add_dependency('reahl-component')

    # The interface for a component is published via the reahl.eggs entry point
    line = 'Egg = reahl.component.eggs:ReahlEgg'
    easter_egg.add_entry_point_from_line('reahl.eggs', line)

    # Interfaces can be queried in dependency order too
    interfaces_in_order = ReahlEgg.compute_all_relevant_interfaces(easter_egg.as_requirement_string())
    assert len(interfaces_in_order) == 2   # That of reahl-component itself, and of the easteregg
    [interface] = [i for i in interfaces_in_order if i.distribution is easter_egg]

    # The meta-info that can be obtained via such an interface
    assert interface.configuration_spec is None

    assert interface.get_persisted_classes_in_order() == []
    assert interface.migrations_in_order == []

    # Hooks for allowing a component to do its own housekeeping
    with expected(NoException):
        interface.do_daily_maintenance()
Exemple #3
0
    def new_config(self):
        line = 'StubDatabaseControl = reahl.component_dev.test_dbutils:StubDatabaseControl'
        easter_egg.add_entry_point_from_line(
            'reahl.component.databasecontrols', line)

        config = Configuration()
        config.reahlsystem = ReahlSystemConfig()
        return config
Exemple #4
0
    def widgets_for_tasks(self, fixture):
        """The widget to use for displaying a particular type of task can be set via an entry point."""
        pkg_resources.working_set.add(easter_egg)
        line = 'MyTaskWidget = reahl.domainui_dev.bootstrap.test_workflow:MyTaskWidget'
        easter_egg.add_entry_point_from_line('reahl.workflowui.task_widgets',
                                             line)

        with fixture.persistent_test_classes(MyTask):
            task = MyTask(queue=fixture.queue, title='a task')

            browser = Browser(fixture.wsgi_app)
            fixture.log_in(browser=browser)
            browser.open('/inbox/task/%s' % task.id)
            html = browser.get_html_for('//div/p')
            vassert(html == '<p>my task widget</p>')
Exemple #5
0
    def new_reader(self):
        easter_egg.add_entry_point_from_line(
            'reahl.dev.xmlclasses',
            'test1 = reahl.dev_dev.test_xmlreader:ConfiguredReader.TestClass1')
        easter_egg.add_entry_point_from_line(
            'reahl.dev.xmlclasses',
            'test2 = reahl.dev_dev.test_xmlreader:ConfiguredReader.TestClass2')

        @stubclass(XMLReader)
        class XMLReaderStub(XMLReader):
            registered = {}

            def register(self, tag_name, class_to_instantiate, type_name=None):
                self.registered[class_to_instantiate] = (tag_name,
                                                         class_to_instantiate,
                                                         type_name)

        return XMLReaderStub()