Skip to content

Commit b4703af

Browse files
committed
fix: adding add button
1 parent 64ad782 commit b4703af

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "edit-python-pe"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "Allows member and project profile editing onto python.pe git repository"
55
readme = "README.md"
66
license = { file = "LICENSE" }

src/edit_python_pe/main.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def on_mount(self) -> None:
5757
self.quit_list_button = Button("Salir", id="quit_list")
5858

5959
self.list_container.mount(self.list_title)
60+
self.add_list_button = Button("Añadir", id="add_list")
6061
self.list_container.mount(self.list_view)
62+
self.list_container.mount(self.add_list_button)
6163
self.list_container.mount(self.quit_list_button)
6264

6365
md_files = glob.glob(
@@ -147,11 +149,11 @@ def clear_form(self) -> None:
147149
self.email_input.value = ""
148150
self.city_input.value = ""
149151
self.homepage_input.value = ""
150-
self.about_me_area.text = ""
151-
self.who_area.text = ""
152-
self.python_area.text = ""
153-
self.contributions_area.text = ""
154-
self.availability_area.text = ""
152+
self.about_me_area.text = "Sobre mí"
153+
self.who_area.text = "¿Quién eres y a qué te dedicas?"
154+
self.python_area.text = "¿Cómo programas en Python?"
155+
self.contributions_area.text = "¿Tienes algún aporte a la comunidad de Python?"
156+
self.availability_area.text = "¿Estás disponible para hacer mentoring, consultorías, charlas?"
155157

156158
for soc in self.social_entries:
157159
soc.remove()
@@ -288,6 +290,10 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
288290
self.add_social_entry()
289291
elif bid == "add_alias":
290292
self.add_alias_entry()
293+
elif bid == "add_list":
294+
self.clear_form()
295+
self.current_file = None
296+
self.show_form()
291297
elif bid == "save":
292298
self.save_member()
293299
elif bid == "back":

tests/test_member_app.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def setUp(self):
1919
self.app = MemberApp(token=self.token, original_repo=self.repo)
2020
self.app.social_container = MagicMock()
2121
self.app.alias_container = MagicMock()
22+
self.app.list_container = MagicMock()
23+
self.app.form_container = MagicMock()
2224
# Manually initialize attributes normally set in on_mount
2325
self.app.social_entries = []
2426
self.app.alias_entries = []
@@ -87,6 +89,41 @@ def stub_add_social_entry():
8789
self.app.add_social_entry()
8890
self.assertEqual(len(self.app.social_entries), initial_count + 1)
8991

92+
def test_add_list_button_clears_form(self):
93+
"""Test that clicking the 'Añadir' button on the list screen clears the form and prepares for a new entry."""
94+
# Fill form fields
95+
self.app.name_input.value = "Filled Name"
96+
self.app.email_input.value = "filled@email.com"
97+
self.app.city_input.value = "Filled City"
98+
self.app.homepage_input.value = "https://filled-homepage.com"
99+
self.app.about_me_area.text = "Filled About me"
100+
self.app.who_area.text = "Filled Who am I"
101+
self.app.python_area.text = "Filled Python stuff"
102+
self.app.contributions_area.text = "Filled Contributions"
103+
self.app.availability_area.text = "Filled Available"
104+
# Add social and alias entries
105+
self.app.social_entries = [self.StubSocialEntry()]
106+
self.app.alias_entries = [self.StubAliasEntry()]
107+
# Simulate pressing the 'Añadir' button on the list screen
108+
class DummyButton:
109+
id = "add_list"
110+
class DummyEvent:
111+
button = DummyButton()
112+
self.app.on_button_pressed(DummyEvent())
113+
# After pressing, form should be cleared and current_file should be None
114+
self.assertEqual(self.app.name_input.value, "")
115+
self.assertEqual(self.app.email_input.value, "")
116+
self.assertEqual(self.app.city_input.value, "")
117+
self.assertEqual(self.app.homepage_input.value, "")
118+
self.assertEqual(self.app.about_me_area.text, "Sobre mí")
119+
self.assertEqual(self.app.who_area.text, "¿Quién eres y a qué te dedicas?")
120+
self.assertEqual(self.app.python_area.text, "¿Cómo programas en Python?")
121+
self.assertEqual(self.app.contributions_area.text, "¿Tienes algún aporte a la comunidad de Python?")
122+
self.assertEqual(self.app.availability_area.text, "¿Estás disponible para hacer mentoring, consultorías, charlas?")
123+
self.assertEqual(len(self.app.social_entries), 0)
124+
self.assertEqual(len(self.app.alias_entries), 0)
125+
self.assertIsNone(self.app.current_file)
126+
90127
def test_add_alias_entry(self):
91128
# Patch add_alias_entry to use stub
92129
self.app.alias_entries = []

0 commit comments

Comments
 (0)