Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scenario filter drops entities when entity alternative has not been given #476

Open
soininen opened this issue Jan 15, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@soininen
Copy link
Collaborator

Consider an entity with entity alternative set for alternative A. In a scenario which contains alternative B but not A, the entity should be visible if its entity class has active_by_default set to true. This is currently not the case: the entity is always hidden.

@soininen soininen added the bug Something isn't working label Jan 15, 2025
@soininen soininen self-assigned this Jan 15, 2025
@soininen
Copy link
Collaborator Author

Dropping a unit test here, ready to be copy-pasted to test_scenario_filter.py demonstrating the bug:

    def test_entity_with_irrelevant_entity_alternative_is_passed(self):
        with TemporaryDirectory() as temp_dir:
            url = "sqlite:///" + str(Path(temp_dir, "db.sqlite"))
            with DatabaseMapping(url, create=True) as db_map:
                self._assert_success(db_map.add_scenario_item(name="Scenario"))
                self._assert_success(db_map.add_entity_class_item(name="Object", active_by_default=True))
                self._assert_success(db_map.add_entity_item(name="cube", entity_class_name="Object"))
                self._assert_success(db_map.add_entity_alternative_item(entity_class_name="Object", entity_byname=("cube",), alternative_name="Base", active=True))
                db_map.commit_session("Add test data")
            with DatabaseMapping(url) as db_map:
                config = scenario_filter_config("Scenario")
                scenario_filter_from_dict(db_map, config)
                entities = db_map.get_entity_items()
                self.assertEqual(len(entities), 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant