3
0
Fork 0

feat: add wizard for generating new master view code

This commit is contained in:
Lance Edgar 2025-12-31 18:52:37 -06:00
parent 92d4ce43b1
commit a62827d2c3
8 changed files with 1690 additions and 4 deletions

View file

@ -90,20 +90,33 @@ version_locations = wuttjamaican.db:alembic/versions
def test_get_xref_buttons(self):
self.pyramid_config.add_route("users", "/users/")
self.pyramid_config.add_route("master_views.create", "/views/master/new")
model = self.app.model
view = self.make_view()
# nb. must add this first
self.pyramid_config.add_wutta_master_view(UserView)
# now xref button should work
table = {"name": "person", "model_class": model.User}
# should be just one xref button by default
table = {"name": "user", "model_class": model.User}
buttons = view.get_xref_buttons(table)
self.assertEqual(len(buttons), 1)
button = buttons[0]
self.assertIn("Users", button)
self.assertIn("http://example.com/users/", button)
# unless we have perm to make new master view
with patch.object(self.request, "is_root", new=True):
table = {"name": "user", "model_class": model.User}
buttons = view.get_xref_buttons(table)
self.assertEqual(len(buttons), 3)
first, second, third = buttons
self.assertIn("Users", first)
self.assertIn("http://example.com/users/", first)
self.assertEqual(second, "<br />")
self.assertIn("New Master View", third)
self.assertIn("http://example.com/views/master/new", third)
def test_get_row_grid_data(self):
model = self.app.model
view = self.make_view()
@ -232,6 +245,7 @@ version_locations = wuttjamaican.db:alembic/versions
result = view.wizard_action()
self.assertIn("error", result)
self.assertEqual(result["error"], "File already exists")
self.assertEqual(os.path.getsize(module_path), 0)
# but it can overwrite if requested
with patch.dict(sample, {"overwrite": True}):