@@ -102,21 +102,34 @@ def test_add_list_button_clears_form(self):
102102 # Add social and alias entries
103103 self .app .social_entries = [self .StubSocialEntry ()]
104104 self .app .alias_entries = [self .StubAliasEntry ()]
105+
105106 # Simulate pressing the 'Añadir' button on the list screen
106107 class DummyButton :
107108 id = "add_list"
109+
108110 class DummyEvent :
109111 button = DummyButton ()
112+
110113 self .app .on_button_pressed (DummyEvent ())
111114 # After pressing, form should be cleared and current_file should be None
112115 self .assertEqual (self .app .name_input .value , "" )
113116 self .assertEqual (self .app .email_input .value , "" )
114117 self .assertEqual (self .app .city_input .value , "" )
115118 self .assertEqual (self .app .homepage_input .value , "" )
116- self .assertEqual (self .app .who_area .text , "¿Quién eres y a qué te dedicas?" )
117- self .assertEqual (self .app .python_area .text , "¿Cómo programas en Python?" )
118- self .assertEqual (self .app .contributions_area .text , "¿Tienes algún aporte a la comunidad de Python?" )
119- self .assertEqual (self .app .availability_area .text , "¿Estás disponible para hacer mentoring, consultorías, charlas?" )
119+ self .assertEqual (
120+ self .app .who_area .text , "¿Quién eres y a qué te dedicas?"
121+ )
122+ self .assertEqual (
123+ self .app .python_area .text , "¿Cómo programas en Python?"
124+ )
125+ self .assertEqual (
126+ self .app .contributions_area .text ,
127+ "¿Tienes algún aporte a la comunidad de Python?" ,
128+ )
129+ self .assertEqual (
130+ self .app .availability_area .text ,
131+ "¿Estás disponible para hacer mentoring, consultorías, charlas?" ,
132+ )
120133 self .assertEqual (len (self .app .social_entries ), 0 )
121134 self .assertEqual (len (self .app .alias_entries ), 0 )
122135 self .assertIsNone (self .app .current_file )
@@ -448,10 +461,13 @@ def stub_add_alias_entry():
448461 self .assertEqual (self .app .homepage_input .value , "https://joe-doe.org" )
449462 self .assertGreaterEqual (len (self .app .social_entries ), 1 )
450463
464+
451465# Test for get_repo function
452466import builtins
467+
453468from edit_python_pe .main import get_repo
454469
470+
455471class TestGetRepo (unittest .TestCase ):
456472 @patch ("edit_python_pe.main.getpass.getpass" , return_value = "valid-token" )
457473 @patch ("edit_python_pe.main.Github" )
@@ -466,27 +482,36 @@ def test_get_repo_success(self, mock_github, mock_getpass):
466482 @patch ("edit_python_pe.main.Github" )
467483 def test_get_repo_bad_credentials (self , mock_github , mock_getpass ):
468484 from github .GithubException import BadCredentialsException
469- mock_github .return_value .get_repo .side_effect = BadCredentialsException (401 , "Bad credentials" , None )
485+
486+ mock_github .return_value .get_repo .side_effect = (
487+ BadCredentialsException (401 , "Bad credentials" , None )
488+ )
470489 with self .assertRaises (SystemExit ):
471490 get_repo ()
472491
473492 @patch ("edit_python_pe.main.getpass.getpass" , return_value = "valid-token" )
474493 @patch ("edit_python_pe.main.Github" )
475494 def test_get_repo_github_exception (self , mock_github , mock_getpass ):
476495 from github .GithubException import GithubException
477- mock_github .return_value .get_repo .side_effect = GithubException (404 , "Not found" , None )
496+
497+ mock_github .return_value .get_repo .side_effect = GithubException (
498+ 404 , "Not found" , None
499+ )
478500 with self .assertRaises (SystemExit ):
479501 get_repo ()
480502
481503
482504from edit_python_pe .main import fork_repo
483505
506+
484507class TestForkRepo (unittest .TestCase ):
485508 @patch ("edit_python_pe.main.user_data_dir" , return_value = "/tmp/testrepo" )
486509 @patch ("edit_python_pe.main.os.path.exists" , return_value = False )
487510 @patch ("edit_python_pe.main.pygit2.clone_repository" )
488511 @patch ("edit_python_pe.main.sleep" , return_value = None )
489- def test_fork_repo_clones_if_not_exists (self , mock_sleep , mock_clone , mock_exists , mock_user_data_dir ):
512+ def test_fork_repo_clones_if_not_exists (
513+ self , mock_sleep , mock_clone , mock_exists , mock_user_data_dir
514+ ):
490515 mock_forked_repo = MagicMock ()
491516 mock_forked_repo .clone_url = "https://github.com/fake/fork.git"
492517 mock_original_repo = MagicMock ()
@@ -502,16 +527,22 @@ def test_fork_repo_clones_if_not_exists(self, mock_sleep, mock_clone, mock_exist
502527 @patch ("edit_python_pe.main.user_data_dir" , return_value = "/tmp/testrepo" )
503528 @patch ("edit_python_pe.main.os.path.exists" , return_value = True )
504529 @patch ("edit_python_pe.main.pygit2.clone_repository" )
505- def test_fork_repo_no_clone_if_exists (self , mock_clone , mock_exists , mock_user_data_dir ):
530+ def test_fork_repo_no_clone_if_exists (
531+ self , mock_clone , mock_exists , mock_user_data_dir
532+ ):
506533 mock_forked_repo = MagicMock ()
507534
535+
508536from edit_python_pe .main import main
509537
538+
510539class TestMainFunction (unittest .TestCase ):
511540 @patch ("edit_python_pe.main.get_repo" )
512541 @patch ("edit_python_pe.main.fork_repo" )
513542 @patch ("edit_python_pe.main.MemberApp" )
514- def test_main_runs_app (self , mock_member_app , mock_fork_repo , mock_get_repo ):
543+ def test_main_runs_app (
544+ self , mock_member_app , mock_fork_repo , mock_get_repo
545+ ):
515546 mock_get_repo .return_value = ("token" , MagicMock ())
516547 mock_fork_repo .return_value = "/tmp/testrepo"
517548 mock_app_instance = MagicMock ()
0 commit comments