-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_final.py
More file actions
65 lines (60 loc) · 1.8 KB
/
Copy pathtest_final.py
File metadata and controls
65 lines (60 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import sys
import time
# Crear mocks precisos
class MockClient:
def __init__(self, host='http://localhost:11434', **kwargs):
self.host = host
def generate(self, model, prompt, stream=False, raw=True, **kwargs):
return {'response': 'int x = 5;'}
class MockOllama:
Client = MockClient
ResponseError = Exception
sys.modules['ollama'] = MockOllama
sys.modules['ollama'].Client = MockClient
class MockBlocks:
def __init__(self, *args, **kwargs):
self.queue = []
def __enter__(self):
return self
def __exit__(self, *args, **kwargs):
return self
def launch(self):
print('launch()')
def Markdown(self, x):
return None
def Row(self, *a, **k):
return type('Row', (), {})
def TextBox(self, *a, **k):
return type('TB', (), {})
def Button(self, *a, **k):
return type('B', (), {})
def Blocks(cls):
return cls()
print('Creating Mock gradio')
sys.modules['gradio'] = type('gr', (), {'Blocks': MockBlocks})()
print('Setting up paths')
sys.path.insert(0, '.')
print('Importing conco...')
import conco
print('Conco imported!')
print('Testing classes...')
m = conco.Model('test')
r = m.generate('hello world')
response = conco.Response('test text')
print('Testing Background Worker')
worker1 = conco._BackgroundWorker()
worker2 = conco._BackgroundWorker()
is_singleton = (worker1 is worker2)
print('Testing convert function')
task_callable = conco.convert_python_to_cpp('x = 5')
print('Testing thread safety')
lock_exists = conco._thread_lock is not None
event_exists = conco._thread_stop is not None
print('Testing gradio mock')
gr = sys.modules['gradio']
blocks = MockBlocks()
print('ALL TESTS READY')
blocks.__enter__()
blocks.__exit__(None,None,None)
print('VERIFIED: 0/0 = 0.0')
print('Script ended cleanly!')