roksta 0.2.3__cp311-cp311-macosx_10_9_universal2.whl → 0.2.5__cp311-cp311-macosx_10_9_universal2.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of roksta might be problematic. Click here for more details.

Files changed (46) hide show
  1. roksta/ai/gemini.cpython-311-darwin.so +0 -0
  2. roksta/ai/generic.cpython-311-darwin.so +0 -0
  3. roksta/ai/llm.cpython-311-darwin.so +0 -0
  4. roksta/ai/openai.cpython-311-darwin.so +0 -0
  5. roksta/ai/tools.cpython-311-darwin.so +0 -0
  6. roksta/chat_workflow.cpython-311-darwin.so +0 -0
  7. roksta/command_handlers.cpython-311-darwin.so +0 -0
  8. roksta/env.cpython-311-darwin.so +0 -0
  9. roksta/extended_text_area.cpython-311-darwin.so +0 -0
  10. roksta/goal_workflow.cpython-311-darwin.so +0 -0
  11. roksta/make_issue.cpython-311-darwin.so +0 -0
  12. roksta/new_features.cpython-311-darwin.so +0 -0
  13. roksta/roksta.cpython-311-darwin.so +0 -0
  14. roksta/utils.cpython-311-darwin.so +0 -0
  15. {roksta-0.2.3.dist-info → roksta-0.2.5.dist-info}/METADATA +1 -1
  16. roksta-0.2.5.dist-info/RECORD +77 -0
  17. {roksta-0.2.3.dist-info → roksta-0.2.5.dist-info}/top_level.txt +1 -0
  18. tests/__init__.py +2 -0
  19. tests/conftest.py +169 -0
  20. tests/functions/__init__.py +2 -0
  21. tests/functions/api_v0_01/__init__.py +2 -0
  22. tests/functions/api_v0_01/test__analytics.py +417 -0
  23. tests/functions/api_v0_01/test__gemini_proxy.py +307 -0
  24. tests/functions/api_v0_01/test__generic_proxy.py +399 -0
  25. tests/functions/api_v0_01/test__get_payment_details.py +356 -0
  26. tests/functions/api_v0_01/test__openai_proxy.py +413 -0
  27. tests/functions/api_v0_01/test__redeem_credit_code.py +167 -0
  28. tests/functions/api_v0_01/test__sync_emails.py +324 -0
  29. tests/functions/api_v0_01/test__take_payment.py +491 -0
  30. tests/functions/api_v0_01/test__use_activation_code.py +437 -0
  31. tests/functions/api_v1_00/__init__.py +2 -0
  32. tests/functions/api_v1_00/test__analytics.py +416 -0
  33. tests/functions/api_v1_00/test__gemini_proxy.py +352 -0
  34. tests/functions/api_v1_00/test__generic_proxy.py +428 -0
  35. tests/functions/api_v1_00/test__get_payment_details.py +356 -0
  36. tests/functions/api_v1_00/test__openai_proxy.py +449 -0
  37. tests/functions/api_v1_00/test__redeem_credit_code.py +167 -0
  38. tests/functions/api_v1_00/test__sync_emails.py +325 -0
  39. tests/functions/api_v1_00/test__take_payment.py +491 -0
  40. tests/functions/api_v1_00/test__use_activation_code.py +438 -0
  41. tests/functions/test_auth.py +24 -0
  42. tests/functions/test_main_functions.py +73 -0
  43. tests/functions/test_utils_functions.py +222 -0
  44. roksta-0.2.3.dist-info/RECORD +0 -51
  45. {roksta-0.2.3.dist-info → roksta-0.2.5.dist-info}/WHEEL +0 -0
  46. {roksta-0.2.3.dist-info → roksta-0.2.5.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,222 @@
1
+ import importlib
2
+ import sys
3
+ import types
4
+ import json
5
+ import pytest
6
+
7
+
8
+ def _setup_basic_stubs(secret_data=b'MY_SECRET', secret_side_effect=None, auth_verify=lambda token: {'uid': 'u1'}):
9
+ """Install minimal stub modules for google.cloud.secretmanager, firebase_functions and firebase_admin.
10
+ Returns a dict of original sys.modules entries for cleanup.
11
+ """
12
+ orig = {}
13
+ names = [
14
+ 'google',
15
+ 'google.cloud',
16
+ 'google.cloud.secretmanager',
17
+ 'firebase_functions',
18
+ 'firebase_admin',
19
+ 'firebase_admin.auth',
20
+ ]
21
+ for name in names:
22
+ orig[name] = sys.modules.get(name)
23
+
24
+ # google package and submodules
25
+ google_mod = types.ModuleType('google')
26
+ cloud_mod = types.ModuleType('google.cloud')
27
+ secretmanager_mod = types.ModuleType('google.cloud.secretmanager')
28
+
29
+ class _Payload:
30
+ def __init__(self, data):
31
+ self.data = data
32
+
33
+ class _Response:
34
+ def __init__(self, data):
35
+ self.payload = _Payload(data)
36
+
37
+ class SecretManagerServiceClient:
38
+ def access_secret_version(self, request=None):
39
+ if secret_side_effect:
40
+ # raise the provided exception instance for testing
41
+ raise secret_side_effect
42
+ return _Response(secret_data)
43
+
44
+ secretmanager_mod.SecretManagerServiceClient = SecretManagerServiceClient
45
+ cloud_mod.secretmanager = secretmanager_mod
46
+ google_mod.cloud = cloud_mod
47
+
48
+ sys.modules['google'] = google_mod
49
+ sys.modules['google.cloud'] = cloud_mod
50
+ sys.modules['google.cloud.secretmanager'] = secretmanager_mod
51
+
52
+ # firebase_functions stub with a Response type expected by utils.create_json_response
53
+ firebase_functions_mod = types.ModuleType('firebase_functions')
54
+
55
+ class FakeResponse:
56
+ def __init__(self, response=None, mimetype=None, status=200, **kwargs):
57
+ self.status_code = status
58
+ if isinstance(response, (dict, list)):
59
+ self._body_text = json.dumps(response)
60
+ else:
61
+ self._body_text = '' if response is None else response
62
+ self.headers = kwargs.get('headers', {})
63
+
64
+ def get_data(self, as_text=False):
65
+ if as_text:
66
+ return self._body_text
67
+ return self._body_text.encode('utf-8')
68
+
69
+ firebase_functions_mod.https_fn = types.SimpleNamespace(Request=object, Response=FakeResponse)
70
+ sys.modules['firebase_functions'] = firebase_functions_mod
71
+
72
+ # firebase_admin + auth stub
73
+ firebase_admin_mod = types.ModuleType('firebase_admin')
74
+ auth_mod = types.ModuleType('firebase_admin.auth')
75
+
76
+ def _verify_id_token(token):
77
+ return auth_verify(token)
78
+
79
+ auth_mod.verify_id_token = _verify_id_token
80
+ firebase_admin_mod.auth = auth_mod
81
+ sys.modules['firebase_admin'] = firebase_admin_mod
82
+ sys.modules['firebase_admin.auth'] = auth_mod
83
+
84
+ return orig
85
+
86
+
87
+ def _restore_orig(orig):
88
+ for name, val in orig.items():
89
+ if val is None:
90
+ if name in sys.modules:
91
+ del sys.modules[name]
92
+ else:
93
+ sys.modules[name] = val
94
+
95
+
96
+ def test_get_secret_key_returns_decoded_string_on_success():
97
+ orig = _setup_basic_stubs(secret_data=b'MY_SECRET')
98
+ try:
99
+ if 'utils' in sys.modules:
100
+ del sys.modules['utils']
101
+ utils = importlib.import_module('utils')
102
+ res = utils.get_secret_key('any')
103
+ assert res == 'MY_SECRET'
104
+ finally:
105
+ _restore_orig(orig)
106
+
107
+
108
+ def test_get_secret_key_raises_exception_on_client_error():
109
+ orig = _setup_basic_stubs(secret_side_effect=Exception('boom'))
110
+ try:
111
+ if 'utils' in sys.modules:
112
+ del sys.modules['utils']
113
+ utils = importlib.import_module('utils')
114
+ with pytest.raises(Exception) as exc:
115
+ utils.get_secret_key('any')
116
+ assert 'Failed to retrieve secret key' in str(exc.value)
117
+ assert 'boom' in str(exc.value)
118
+ finally:
119
+ _restore_orig(orig)
120
+
121
+
122
+ def test_verify_firebase_token_raises_when_header_missing_or_invalid():
123
+ orig = _setup_basic_stubs()
124
+ try:
125
+ if 'utils' in sys.modules:
126
+ del sys.modules['utils']
127
+ utils = importlib.import_module('utils')
128
+
129
+ class DummyRequest:
130
+ def __init__(self, headers=None):
131
+ self.headers = headers or {}
132
+
133
+ # Missing header
134
+ req = DummyRequest(headers={})
135
+ with pytest.raises(Exception) as exc:
136
+ utils.verify_firebase_token(req)
137
+ assert 'Missing or invalid Authorization header' in str(exc.value)
138
+
139
+ # Header present but not starting with 'Bearer '
140
+ req2 = DummyRequest(headers={'Authorization': 'Token abc'})
141
+ with pytest.raises(Exception) as exc2:
142
+ utils.verify_firebase_token(req2)
143
+ assert 'Missing or invalid Authorization header' in str(exc2.value)
144
+ finally:
145
+ _restore_orig(orig)
146
+
147
+
148
+ def test_verify_firebase_token_calls_auth_verify_and_returns_payload():
149
+ orig = _setup_basic_stubs(auth_verify=lambda token: {'uid': 'user_1'})
150
+ try:
151
+ if 'utils' in sys.modules:
152
+ del sys.modules['utils']
153
+ utils = importlib.import_module('utils')
154
+
155
+ class DummyRequest:
156
+ def __init__(self, headers=None):
157
+ self.headers = headers or {}
158
+
159
+ req = DummyRequest(headers={'Authorization': 'Bearer TOK'})
160
+ res = utils.verify_firebase_token(req)
161
+ assert res == {'uid': 'user_1'}
162
+ finally:
163
+ _restore_orig(orig)
164
+
165
+
166
+ def test_verify_firebase_token_wraps_auth_exceptions():
167
+ def _raiser(token):
168
+ raise Exception('bad token')
169
+
170
+ orig = _setup_basic_stubs(auth_verify=_raiser)
171
+ try:
172
+ if 'utils' in sys.modules:
173
+ del sys.modules['utils']
174
+ utils = importlib.import_module('utils')
175
+
176
+ class DummyRequest:
177
+ def __init__(self, headers=None):
178
+ self.headers = headers or {}
179
+
180
+ req = DummyRequest(headers={'Authorization': 'Bearer TOK'})
181
+ with pytest.raises(Exception) as exc:
182
+ utils.verify_firebase_token(req)
183
+ assert 'Authentication failed' in str(exc.value)
184
+ assert 'bad token' in str(exc.value)
185
+ finally:
186
+ _restore_orig(orig)
187
+
188
+
189
+ def test_get_api_key_uses_lowercase_family_name_and_get_secret_key(monkeypatch):
190
+ orig = _setup_basic_stubs()
191
+ try:
192
+ if 'utils' in sys.modules:
193
+ del sys.modules['utils']
194
+ utils = importlib.import_module('utils')
195
+
196
+ called = {}
197
+
198
+ def fake_get_secret_key(name):
199
+ called['name'] = name
200
+ return 'THE_KEY'
201
+
202
+ monkeypatch.setattr(utils, 'get_secret_key', fake_get_secret_key)
203
+ from enums import LlmFamily
204
+ res = utils.get_api_key(LlmFamily.OPENAI)
205
+ assert res == 'THE_KEY'
206
+ assert called['name'] == 'openai-api-key'
207
+ finally:
208
+ _restore_orig(orig)
209
+
210
+
211
+ def test_create_json_response_returns_formatted_response():
212
+ orig = _setup_basic_stubs()
213
+ try:
214
+ if 'utils' in sys.modules:
215
+ del sys.modules['utils']
216
+ utils = importlib.import_module('utils')
217
+ resp = utils.create_json_response(True, {'a': 1}, 201)
218
+ assert getattr(resp, 'status_code', None) == 201
219
+ data = json.loads(resp.get_data(as_text=True))
220
+ assert data == {"success": True, "payload": {"a": 1}}
221
+ finally:
222
+ _restore_orig(orig)
@@ -1,51 +0,0 @@
1
- roksta/logger.cpython-311-darwin.so,sha256=xch275vL4nC3HeSUxVdjTpnXmRXq2Jd1auVsd-a3bNs,122016
2
- roksta/lint_code.cpython-311-darwin.so,sha256=A0gUSQhdeoxwvZsTBQS_IPqpb9wSLfmFzk3FDzFVUSI,207840
3
- roksta/get_codebase_structure.cpython-311-darwin.so,sha256=gFFoEJU2H9vJgmbRWjcqY2tSqc_7eUJPWIGTDgSQZk4,189984
4
- roksta/checkpoints.cpython-311-darwin.so,sha256=4vZMS8o8V6fez18V-ln64U4tXsOBPqbGgLE7pyYhZkQ,238032
5
- roksta/extended_text_area.cpython-311-darwin.so,sha256=1yzo2-fFSXgCeZodp2eYpKzrn_lvfKN2puNSj6vVLdQ,290664
6
- roksta/firebase_config.cpython-311-darwin.so,sha256=BKPNge6g8lDyI4M6dAxXVasD1T-j9stNUT--pB-AGT8,86568
7
- roksta/init_codebase.cpython-311-darwin.so,sha256=nRfr4ich8gyIq3i6RtzAuvIb2JpNkVKVlX8btOLeSUM,275024
8
- roksta/gen_one_line_goal.cpython-311-darwin.so,sha256=LGggcZkhy9W8RTUIzj9vcACw0KZs7Big3_TpTXE3IZc,207560
9
- roksta/new_features.cpython-311-darwin.so,sha256=yDRUfafgJTK_3XcRnD6XIL4efUvL0i89Po8pybxkLyc,85632
10
- roksta/chat_workflow.cpython-311-darwin.so,sha256=EULZ5NweWefw6F1hmeIH_trh4CcWh5olLKN-MY1KEt0,224240
11
- roksta/select_files.cpython-311-darwin.so,sha256=Qbce978o2zTA1wLVw2pHtNvhJJWhhUGHRuC5C57H_XM,207600
12
- roksta/parse_readme.cpython-311-darwin.so,sha256=I2kO1om8ONYzY9LR4kSINOwLO6GZUU9A5M0naoxfYVY,190576
13
- roksta/firebase.cpython-311-darwin.so,sha256=AhLG5dRIzo31Qakmg5nS_Mi-Fxt6mUt892vm840fPw4,438704
14
- roksta/goal_workflow.cpython-311-darwin.so,sha256=pDHwe5Qxgx3gdPDylMMRscz2-I-b0Ux2vLa3Iw1Pzk8,471536
15
- roksta/tips.cpython-311-darwin.so,sha256=G5uOnowxuWhZB2w9smL-5ZofdJepbxXDCUzp2XBZES8,85592
16
- roksta/write_code.cpython-311-darwin.so,sha256=U_6AsReL8Kxv8TwuscxLySI4jL7dQa-rFgft7kLeYCQ,190944
17
- roksta/enums.cpython-311-darwin.so,sha256=rGABZEs5M_6PDdxssR9-gwfDhqMoor9kOyoxf79VFnI,404232
18
- roksta/analytics.cpython-311-darwin.so,sha256=G_vahLnIIUy40canNVoeC4vCVxR59t83RPsgekD68Rk,256560
19
- roksta/command_handlers.cpython-311-darwin.so,sha256=ZQbK08qw-2WKM1WvuJlaeOlErmZDQufOFnEIA-Nnx4s,884136
20
- roksta/main.cpython-311-darwin.so,sha256=qvaLiRuOm-xKWes-_OrkCVwZ9D_8CbuVXrVKkvZn-OY,87848
21
- roksta/response_formats.cpython-311-darwin.so,sha256=BthAKv6MpQLL6SPni865ADEgw9VQwy-w1kgEEev-xGY,153928
22
- roksta/check_for_updates.cpython-311-darwin.so,sha256=EIzhYwVdNbLoUt3EGsUdR3eN1sHqXsFcCrIYeqF41LY,190264
23
- roksta/utils.cpython-311-darwin.so,sha256=JE61rBwcl6YXIPkXQdgz3TYzU2k1PNw9lFRXNbvtDEw,539320
24
- roksta/fix_tests.cpython-311-darwin.so,sha256=GatMUu0o2CrFjYFyMazxkfW-wg4_1Eg8IA1N4Hkw3E8,223984
25
- roksta/firebase_auth_web.cpython-311-darwin.so,sha256=rzgbsHUqV2tRUsLvaYfCoapLkMEux3RqSXwDtAFKUgo,439656
26
- roksta/env.cpython-311-darwin.so,sha256=6YuoG09Sm1WneQI-fi3LV2RJvbX4DbSfPCfq-qir6Vc,87992
27
- roksta/get_failing_tests.cpython-311-darwin.so,sha256=1jvAcZKA8gsnsrq6-HNsro-rQkqesYZIi9nKhf8g5m8,207576
28
- roksta/clarify_goal.cpython-311-darwin.so,sha256=9GRKv1QrjNCoulhg7BxAMwKItzLaI1XGcADo0lFCaYY,207616
29
- roksta/roksta.cpython-311-darwin.so,sha256=xdY1CQpuzW6CSJv8lSo2EsLUaeEsWXHDueq_eO9hQ8k,538720
30
- roksta/build_project.cpython-311-darwin.so,sha256=vUvI_82FBp5at73GbjzytM40VdyuxNrMSoy-TF0_hW0,190992
31
- roksta/rewrite_goal.cpython-311-darwin.so,sha256=Ef34h7nGUNKgGcRQY2EKLKkSrcNLKp4xzKE9JTmg6QY,174512
32
- roksta/codebase_listing.cpython-311-darwin.so,sha256=yqwkwIMP3MKag60iU2LEYWt36jCXgjmnFL7UuKiUUaQ,155656
33
- roksta/default_config.cpython-311-darwin.so,sha256=kSxB1gzC1tdg9b5CN0K3aAuD6zVFrt8sOgTjB3l3Mz4,102152
34
- roksta/__init__.cpython-311-darwin.so,sha256=0ErvE_Ab31A1ApkmxEhfJuljCTrEA6VccImUD3_9z8U,85488
35
- roksta/create_default_config.cpython-311-darwin.so,sha256=6XuYR51E9xZ54eSdTRZzlsN1ywGP5EuVUTHnC6L0ljU,121672
36
- roksta/make_issue.cpython-311-darwin.so,sha256=KPFxHWzjp3DpXiwnU4GuI8HCxY5u68x534jn-M9iiAk,189152
37
- roksta/propose_solution.cpython-311-darwin.so,sha256=wCKK0fp40j_ewRIzxF1PYqmUGkE3i4iGnp6tTB0A9Vc,190920
38
- roksta/balance.cpython-311-darwin.so,sha256=QpRQuVdggsFhQDW6uvrA9fSY7lHskliMkm4oVOMc9S8,323856
39
- roksta/gen_codebase_summaries.cpython-311-darwin.so,sha256=kMFynDWJ0D4uosbLAxirjpd3Oe3jOK_TgcJexGFWigA,621344
40
- roksta/ai/tools.cpython-311-darwin.so,sha256=WOEQ78Xl_npRnuvpgCmQiT12XVHlkzVH0L5SSblZryM,604392
41
- roksta/ai/openai.cpython-311-darwin.so,sha256=UTE-LQ3MHWAZYQkRjLazRafUvq1vpV3TF5EMWTRdPrQ,290384
42
- roksta/ai/call_ai.cpython-311-darwin.so,sha256=ha__TxFymsSiqhMesb7AJScC5UMt2YkDMoTuHxYND2k,224048
43
- roksta/ai/llm.cpython-311-darwin.so,sha256=ayi92VggDSylZ2owvihS4SOYOthhZaLC3UAdJ3tZ9lI,288248
44
- roksta/ai/gemini.cpython-311-darwin.so,sha256=ga0YMVX45j0nXXDGhnqWwztMtd6Eytq6EOuA5A0_oeI,406064
45
- roksta/ai/generic.cpython-311-darwin.so,sha256=g_NdDNFTN40TMi65VA8aCYtPnoM4Xx9-4wFsaxhQXcM,306720
46
- roksta/ai/__init__.cpython-311-darwin.so,sha256=dpXQ14GwJxUat0fxONmbamSbzHo2JsnZHVeNP3LY_No,85488
47
- roksta-0.2.3.dist-info/RECORD,,
48
- roksta-0.2.3.dist-info/WHEEL,sha256=VWNc5NH4DDoQDkc74R-nMZPza3RGJ6ac2abjVbvC-0k,141
49
- roksta-0.2.3.dist-info/entry_points.txt,sha256=mzRdYg_DlzZRwjxYUt9-gyoRCkM1QBTeTbwETgiTdGw,44
50
- roksta-0.2.3.dist-info/top_level.txt,sha256=Worlz0mMqoxRSgPmoN1j_P-sJgIrmzD0uJ08qJwpWpQ,7
51
- roksta-0.2.3.dist-info/METADATA,sha256=EM6b_OmBi1w1sDNXGI9TqtEhtbgkSvGzbCGK8uZ-dHE,1427
File without changes