Skip to main content
Glama
test_server.cpython-312-pytest-8.3.4.pyc11 kB
� ��g�'� ��ddlZddlmcmZddlmZmZmZddl m Z m Z m Z ddl Z ddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd l m!Z!ddl"m#Z#dZ$dZ%dZ&dZ'e%dddddd�Z(e'ejR�jU�dde&ddde%d� Z+e&ddddd �Z,e jZd!��Z.e jZd"��Z/e jZd#��Z0e jZd$��Z1e jZd%��Z2e jZd&��Z3e jZd'��Z4e jZd(��Z5e jZd)��Z6e jZd*��Z7e jZd+��Z8e jZd,��Z9Gd-�d.�Z:Gd/�d0�Z;e jxjzGd1�d2��Z>e jxjzGd3�d4��Z?y)5�N)�date�datetime� timedelta)� AsyncMock� MagicMock�patch)� AccountsApi)� BudgetsApi)� CategoriesApi)�TransactionsApi)� ApiClient)�Account)� BudgetSummary)�Category)�CategoryGroupWithCategories)�TransactionDetail�� YNABResourcesztest-budget-123ztest-account-456ztest-category-789ztest-transaction-012z Test Account�checkingi��F)�id�name�type�balance�closed�deletedi�<��z Test PayeezTest transactionT) rr�amount� payee_name� category_id�memo�cleared�approved� account_idz Test Categoryi@ i�I)rr�budgeted�activityrc#�K�td�5}tt��}||_|��ddd�y#1swYyxYw�w)zMock YNAB API client.zmcp_ynab.server._get_client��specN)rrr � return_value)�mock_get_client�clients �D/Users/home/1-Dev-Projects/mcp-servers/ynab-mcp/tests/test_server.py�mock_ynab_clientr,6s5���� �,� -��� �*��'-��$�� � .� -� -��� ?�3� ?�<�?c#�K�td�5}tt��}||_|��ddd�y#1swYyxYw�w)zMock YNAB Budgets API.zynab.api.budgets_api.BudgetsApir&N)rrr r(��mock_api�apis r+�mock_budgets_apir2>s5���� �0� 1�X��Z�(�� #���� � 2� 1� 1�r-c#�K�td�5}tt��}||_|��ddd�y#1swYyxYw�w)zMock YNAB Accounts API.z!ynab.api.accounts_api.AccountsApir&N)rrr r(r/s r+�mock_accounts_apir4Fs5���� �2� 3�x��[�)�� #���� � 4� 3� 3�r-c#�K�td�5}tt��}||_|��ddd�y#1swYyxYw�w)zMock YNAB Categories API.z%ynab.api.categories_api.CategoriesApir&N)rrr r(r/s r+�mock_categories_apir6Ns5���� �6� 7�8��]�+�� #���� � 8� 7� 7�r-c#�K�td�5}tt��}||_|��ddd�y#1swYyxYw�w)zMock YNAB Transactions API.z)ynab.api.transactions_api.TransactionsApir&N)rrr r(r/s r+�mock_transactions_apir8Vs5���� �:� ;�x��_�-�� #���� � <� ;� ;�r-c#�K�|dz }|j�tdt|��5|��ddd�y#1swYyxYw�w)zMock XDG_CONFIG_HOME directory.�configzmcp_ynab.server.XDG_CONFIG_HOMEN)�mkdirr�str)�tmp_path� config_dirs r+�mock_xdg_config_homer?^s?�����H�$�J����� �0�#�j�/� B��� C� B� B�s�+A�;� A�A�Ac��t�S)z=Create a YNABResources instance with mocked config directory.r)r?s r+�ynab_resourcesrAfs �� �?��c�J�ttdtj���S)zCreate a sample BudgetSummary.z Test Budget)rr�last_modified_on)r�TEST_BUDGET_IDr�now�rBr+�sample_budget_summaryrHks �� � � �!���� �rBc� �tdit��S)zCreate a sample Account.rG)r�SAMPLE_ACCOUNTrGrBr+�sample_accountrKts�� � $�^� $�$rBc� �tdit��S)z"Create a sample TransactionDetail.rG)r�SAMPLE_TRANSACTIONrGrBr+�sample_transactionrNys�� � 2�1� 2�2rBc� �tdit��S)zCreate a sample Category.rG)r�SAMPLE_CATEGORYrGrBr+�sample_categoryrQ~s�� � &�o� &�&rBc�0�tddt�g��S)z,Create a sample CategoryGroupWithCategories.ztest-group-123z Test Group)rr� categories)rrQrGrBr+�sample_category_grouprT�s �� '� � �#�%�&� �rBc��eZdZd�Zd�Zd�Zy)�TestHelperFunctionsc�$�ddg}ddgddgg}ddg}y ) z$Test _build_markdown_table function.�Name�Value�Test1�100�Test2�200�left�rightNrG)�self�headers�rows� alignmentss r+�test_build_markdown_tablez-TestHelperFunctions.test_build_markdown_table�s/���7�#�� �e� � �e� � ���g�&� rBc��y)z&Test _format_accounts_output function.NrG�r`s r+�test_format_accounts_outputz/TestHelperFunctions.test_format_accounts_output���rBc��y)z3Test _load_json_file and _save_json_file functions.NrG)r`r=s r+�test_load_save_json_filez,TestHelperFunctions.test_load_save_json_file�rhrBN)�__name__� __module__� __qualname__rdrgrjrGrBr+rVrV�s��'�5�BrBrVc�$�eZdZd�Zd�Zd�Zd�Zy)�TestYNABResourcesc��y)z7Test YNABResources initialization loads data correctly.NrG)r`rAr?s r+�test_init_loads_dataz&TestYNABResources.test_init_loads_data�rhrBc��y)z-Test getting and setting preferred budget ID.NrG�r`rAs r+� test_get_set_preferred_budget_idz2TestYNABResources.test_get_set_preferred_budget_id�rhrBc��y)z"Test retrieving cached categories.NrGrss r+�test_get_cached_categoriesz,TestYNABResources.test_get_cached_categories�rhrBc��y)zTest caching categories.NrGrss r+�test_cache_categoriesz'TestYNABResources.test_cache_categories�rhrBN)rkrlrmrqrtrvrxrGrBr+roro�s��F� <� 1� 'rBroc�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z y ) � TestMCPToolsc�� K�y�w)zTest create_transaction tool.NrG�r`r,r8rNs r+�test_create_transactionz$TestMCPTools.test_create_transaction�s ���� ���c�� K�y�w)zTest get_account_balance tool.NrG�r`r,r4rKs r+�test_get_account_balancez%TestMCPTools.test_get_account_balance������r~c�� K�y�w)zTest get_budgets tool.NrG)r`r,r2rHs r+�test_get_budgetszTestMCPTools.test_get_budgets�r�r~c�� K�y�w)zTest get_accounts tool.NrGr�s r+�test_get_accountszTestMCPTools.test_get_accounts�r�r~c�� K�y�w)zTest get_transactions tool.NrGr|s r+�test_get_transactionsz"TestMCPTools.test_get_transactions�r�r~c�� K�y�w)z-Test get_transactions_needing_attention tool.NrGr|s r+�'test_get_transactions_needing_attentionz4TestMCPTools.test_get_transactions_needing_attention�r�r~c�� K�y�w)z!Test categorize_transaction tool.NrGr|s r+�test_categorize_transactionz(TestMCPTools.test_categorize_transaction�r�r~c�� K�y�w)zTest get_categories tool.NrG)r`r,r6rTs r+�test_get_categoriesz TestMCPTools.test_get_categories�r�r~c�� K�y�w)z"Test set_preferred_budget_id tool.NrGrss r+�test_set_preferred_budget_idz)TestMCPTools.test_set_preferred_budget_idr�r~c�� K�y�w)zTest cache_categories tool.NrG)r`r,r6rArTs r+rxz"TestMCPTools.test_cache_categoriesr�r~N) rkrlrmr}r�r�r�r�r�r�r�r�rxrGrBr+rzrz�s4�� �-�%�&�*�<�0�(�1�*rBrzc��eZdZd�Zd�Zy)� TestAPIClientc�� K�y�w)zTest _get_client function.NrGrfs r+�test_get_clientzTestAPIClient.test_get_clientr�r~c�� K�y�w)z%Test AsyncYNABClient context manager.NrG)r`r,s r+�test_client_context_managerz)TestAPIClient.test_client_context_manager"r�r~N)rkrlrmr�r�rGrBr+r�r�s ��)�4rBr�)@�builtins� @py_builtins�_pytest.assertion.rewrite� assertion�rewrite� @pytest_arrrr� unittest.mockrrr�pytest�ynab.api.accounts_apir �ynab.api.budgets_apir �ynab.api.categories_apir �ynab.api.transactions_apir �ynab.api_clientr �ynab.models.accountr�ynab.models.budget_summaryr�ynab.models.categoryr�*ynab.models.category_group_with_categoriesr�ynab.models.transaction_detailr�mcp_ynab.serverrrE�TEST_ACCOUNT_ID�TEST_CATEGORY_ID�TEST_TRANSACTION_IDrJ�today� isoformatrMrP�fixturer,r2r4r6r8r?rArHrKrNrQrTrVro�mark�asynciorzr�rGrBr+�<module>r�s;����.�.�5�5� �-�+�1�5�%�'�4�)�R�<�)�#��$��&��,�� � � ���� �� � �D�J�J�L� "� "� $���#� ���!� �� � ���� �����������������������������������������������������%��%����3��3����'��'�������B�B�<'�'�2�����M*�M*��M*�h����� 4� 4�� 4rB

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Meh-S-Eze/ynab-mcp-client2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server