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

Separate table class definition and instantiation in MultiTableMixin #876 #885

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

gb119
Copy link

@gb119 gb119 commented Jan 21, 2023

I accidentally closed the earlier pull request, but this doe the same but against the current master (sorry!)

This adds a MultiTableMixin.get_tables_classes() that returns an iterable of table classes to allow this to be customised at run time without overriding the whole get_tables() method.

From previous comments:

  1. Switched from str.format to f-strings
  2. Redid the test case for the new MultiTableMixin.get_tables_classes to check that the rendered output does have two tables - thus checking that the get_tables_classes was used.

fixes: #875

@jieter jieter changed the title Redo: Separate table class definition and instantiation in MultiTableMixin #876 Separate table class definition and instantiation in MultiTableMixin #876 Feb 1, 2023
Copy link
Owner

@jieter jieter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gb119 thanks!

Found one small typo and I have a last question.

if len(data) != len(tables):
klass = type(self).__name__
raise ImproperlyConfigured(f"len({klass}.tables_data) != len({klass}.tables)")
return list(Table(data[i], **kwargs) for i, Table in enumerate(tables))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would one specify the kwargs passed through here?

html = response.rendered_content
self.assertIn("<h1>Multiple tables using MultiTableMixin</h1>", html)

def test_with_empty_get_tables_clases_list(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_with_empty_get_tables_clases_list(self):
def test_with_empty_get_tables_classes_list(self):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Differences between SingleTableMixin and MultiTableMixin?
2 participants