|
18 | 18 | # First-Party |
19 | 19 | from cforge.commands.settings.profiles import ( |
20 | 20 | profiles_create, |
21 | | - profiles_current, |
22 | 21 | profiles_get, |
23 | 22 | profiles_list, |
24 | 23 | profiles_switch, |
@@ -535,108 +534,6 @@ def test_profiles_switch_failed_to_switch(self, mock_console, mock_settings) -> |
535 | 534 | assert any("Failed to switch to profile" in str(call) for call in mock_console.print.call_args_list) |
536 | 535 |
|
537 | 536 |
|
538 | | -class TestProfilesCurrent: |
539 | | - """Tests for profiles current command.""" |
540 | | - |
541 | | - def test_profiles_current_success(self, mock_console, mock_settings) -> None: |
542 | | - """Test showing the current profile.""" |
543 | | - profile = AuthProfile( |
544 | | - id="profile-1", |
545 | | - name="Current Profile", |
546 | | - email="current@example.com", |
547 | | - apiUrl="https://api.example.com", |
548 | | - isActive=True, |
549 | | - createdAt=datetime.now(), |
550 | | - metadata=ProfileMetadata(environment="production"), |
551 | | - ) |
552 | | - |
553 | | - store = ProfileStore( |
554 | | - profiles={"profile-1": profile}, |
555 | | - activeProfileId="profile-1", |
556 | | - ) |
557 | | - save_profile_store(store) |
558 | | - |
559 | | - with patch("cforge.commands.settings.profiles.get_console", return_value=mock_console): |
560 | | - profiles_current() |
561 | | - |
562 | | - # Verify current profile was shown |
563 | | - print_calls = [str(call) for call in mock_console.print.call_args_list] |
564 | | - assert any("Current Profile" in call for call in print_calls) |
565 | | - assert any("current@example.com" in call for call in print_calls) |
566 | | - assert any("production" in call for call in print_calls) |
567 | | - |
568 | | - def test_profiles_current_none_set(self, mock_console, mock_settings) -> None: |
569 | | - """Test showing current profile when none is set (should show default).""" |
570 | | - with patch("cforge.commands.settings.profiles.get_console", return_value=mock_console): |
571 | | - profiles_current() |
572 | | - |
573 | | - # Should show the virtual default profile |
574 | | - print_calls = [str(call) for call in mock_console.print.call_args_list] |
575 | | - assert any("Local Default" in call for call in print_calls) |
576 | | - |
577 | | - def test_profiles_current_with_environment(self, mock_console, mock_settings) -> None: |
578 | | - """Test showing current profile with environment metadata.""" |
579 | | - profile = AuthProfile( |
580 | | - id="profile-1", |
581 | | - name="Current Profile", |
582 | | - email="current@example.com", |
583 | | - apiUrl="https://api.example.com", |
584 | | - isActive=True, |
585 | | - createdAt=datetime.now(), |
586 | | - metadata=ProfileMetadata(environment="staging"), |
587 | | - ) |
588 | | - |
589 | | - store = ProfileStore( |
590 | | - profiles={"profile-1": profile}, |
591 | | - activeProfileId="profile-1", |
592 | | - ) |
593 | | - save_profile_store(store) |
594 | | - |
595 | | - with patch("cforge.commands.settings.profiles.get_console", return_value=mock_console): |
596 | | - profiles_current() |
597 | | - |
598 | | - # Verify environment is shown |
599 | | - print_calls = [str(call) for call in mock_console.print.call_args_list] |
600 | | - assert any("Environment" in call and "staging" in call for call in print_calls) |
601 | | - |
602 | | - def test_profiles_current_error(self, mock_console, mock_settings) -> None: |
603 | | - """Test showing current profile with an error.""" |
604 | | - with patch("cforge.commands.settings.profiles.get_console", return_value=mock_console): |
605 | | - with patch("cforge.commands.settings.profiles.get_active_profile", side_effect=Exception("Test error")): |
606 | | - with pytest.raises(typer.Exit) as exc_info: |
607 | | - profiles_current() |
608 | | - |
609 | | - assert exc_info.value.exit_code == 1 |
610 | | - assert any("Error retrieving current profile" in str(call) for call in mock_console.print.call_args_list) |
611 | | - |
612 | | - def test_profiles_current_no_environment(self, mock_console, mock_settings) -> None: |
613 | | - """Test showing the current profile works when environment is unset.""" |
614 | | - profile = AuthProfile( |
615 | | - id="profile-1", |
616 | | - name="Current Profile", |
617 | | - email="current@example.com", |
618 | | - apiUrl="https://api.example.com", |
619 | | - isActive=True, |
620 | | - createdAt=datetime.now(), |
621 | | - metadata=ProfileMetadata(isInternal=True), |
622 | | - ) |
623 | | - |
624 | | - store = ProfileStore( |
625 | | - profiles={"profile-1": profile}, |
626 | | - activeProfileId="profile-1", |
627 | | - ) |
628 | | - save_profile_store(store) |
629 | | - |
630 | | - with patch("cforge.commands.settings.profiles.get_console", return_value=mock_console): |
631 | | - profiles_current() |
632 | | - |
633 | | - # Verify current profile was shown |
634 | | - print_calls = [str(call) for call in mock_console.print.call_args_list] |
635 | | - assert any("Current Profile" in call for call in print_calls) |
636 | | - assert any("current@example.com" in call for call in print_calls) |
637 | | - assert not any("Environment:" in call for call in print_calls) |
638 | | - |
639 | | - |
640 | 537 | class TestProfilesCreate: |
641 | 538 | """Tests for profiles create command.""" |
642 | 539 |
|
|
0 commit comments