|
| 1 | +# stub out plpy |
| 2 | +from . import plpy |
| 3 | +import sys |
| 4 | +sys.modules['plpy'] = plpy |
| 5 | + |
| 6 | +import time |
| 7 | +import unittest |
| 8 | +from pgml import model |
| 9 | + |
| 10 | +class TestModel(unittest.TestCase): |
| 11 | + def test_the_world(self): |
| 12 | + plpy.add_mock_result( |
| 13 | + [{"id": 1, "name": "Test", "objective": "regression", "created_at": time.time(), "updated_at": time.time()}] |
| 14 | + ) |
| 15 | + plpy.add_mock_result( |
| 16 | + [{"id": 1, "relation_name": "test", "y_column_name": "test_y", "test_size": 0.1, "test_sampling": "random", "status": "new", "created_at": time.time(), "updated_at": time.time()}] |
| 17 | + ) |
| 18 | + plpy.add_mock_result( |
| 19 | + "OK" |
| 20 | + ) |
| 21 | + plpy.add_mock_result( |
| 22 | + [{"id": 1, "relation_name": "test", "y_column_name": "test_y", "test_size": 0.1, "test_sampling": "random", "status": "created", "created_at": time.time(), "updated_at": time.time()}] |
| 23 | + ) |
| 24 | + plpy.add_mock_result( |
| 25 | + [{"id": 1, "project_id": 1, "snapshot_id": 1, "algorithm_name": "linear", "status": "new", "r2_score": None, "mean_squared_error": None, "pickle": None, "created_at": time.time(), "updated_at": time.time()}] |
| 26 | + ) |
| 27 | + plpy.add_mock_result( |
| 28 | + [ |
| 29 | + {"a": 1, "b": 2, "test_y": 3}, |
| 30 | + {"a": 2, "b": 3, "test_y": 4}, |
| 31 | + {"a": 3, "b": 4, "test_y": 5}, |
| 32 | + ] |
| 33 | + ) |
| 34 | + plpy.add_mock_result( |
| 35 | + [{"id": 1, "project_id": 1, "snapshot_id": 1, "algorithm_name": "linear", "status": "new", "r2_score": None, "mean_squared_error": None, "pickle": None, "created_at": time.time(), "updated_at": time.time()}] |
| 36 | + ) |
| 37 | + |
| 38 | + plpy.add_mock_result( |
| 39 | + [{"id": 1, "project_id": 1, "snapshot_id": 1, "algorithm_name": "linear", "status": "new", "r2_score": None, "mean_squared_error": None, "pickle": None, "created_at": time.time(), "updated_at": time.time()}] |
| 40 | + ) |
| 41 | + plpy.add_mock_result( |
| 42 | + [ |
| 43 | + {"a": 1, "b": 2, "test_y": 3}, |
| 44 | + {"a": 2, "b": 3, "test_y": 4}, |
| 45 | + {"a": 3, "b": 4, "test_y": 5}, |
| 46 | + ] |
| 47 | + ) |
| 48 | + plpy.add_mock_result( |
| 49 | + [{"id": 1, "project_id": 1, "snapshot_id": 1, "algorithm_name": "linear", "status": "new", "r2_score": None, "mean_squared_error": None, "pickle": None, "created_at": time.time(), "updated_at": time.time()}] |
| 50 | + ) |
| 51 | + |
| 52 | + plpy.add_mock_result( |
| 53 | + [{"id": 1, "project_id": 1, "snapshot_id": 1, "algorithm_name": "linear", "status": "new", "r2_score": None, "mean_squared_error": None, "pickle": None, "created_at": time.time(), "updated_at": time.time()}] |
| 54 | + ) |
| 55 | + plpy.add_mock_result( |
| 56 | + [ |
| 57 | + {"a": 1, "b": 2, "test_y": 3}, |
| 58 | + {"a": 2, "b": 3, "test_y": 4}, |
| 59 | + {"a": 3, "b": 4, "test_y": 5}, |
| 60 | + ] |
| 61 | + ) |
| 62 | + plpy.add_mock_result( |
| 63 | + [{"id": 1, "project_id": 1, "snapshot_id": 1, "algorithm_name": "linear", "status": "new", "r2_score": None, "mean_squared_error": None, "pickle": None, "created_at": time.time(), "updated_at": time.time()}] |
| 64 | + ) |
| 65 | + model.train("Test", "regression", "test", "test_y") |
0 commit comments