Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

test_config.py 1.9 KB

You have to be logged in to leave a comment. Sign In
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
66
67
68
69
70
71
72
73
74
75
76
  1. import json
  2. import logging
  3. import os
  4. import joblib
  5. import pytest
  6. from prediction_service.prediction import form_response, api_response
  7. import prediction_service
  8. input_data = {
  9. "incorrect_range":
  10. {"fixed_acidity": 7897897,
  11. "volatile_acidity": 555,
  12. "citric_acid": 99,
  13. "residual_sugar": 99,
  14. "chlorides": 12,
  15. "free_sulfur_dioxide": 789,
  16. "total_sulfur_dioxide": 75,
  17. "density": 2,
  18. "pH": 33,
  19. "sulphates": 9,
  20. "alcohol": 9
  21. },
  22. "correct_range":
  23. {"fixed_acidity": 5,
  24. "volatile_acidity": 1,
  25. "citric_acid": 0.5,
  26. "residual_sugar": 10,
  27. "chlorides": 0.5,
  28. "free_sulfur_dioxide": 3,
  29. "total_sulfur_dioxide": 75,
  30. "density": 1,
  31. "pH": 3,
  32. "sulphates": 1,
  33. "alcohol": 9
  34. },
  35. "incorrect_col":
  36. {"fixed acidity": 5,
  37. "volatile acidity": 1,
  38. "citric acid": 0.5,
  39. "residual sugar": 10,
  40. "chlorides": 0.5,
  41. "free sulfur dioxide": 3,
  42. "total_sulfur dioxide": 75,
  43. "density": 1,
  44. "pH": 3,
  45. "sulphates": 1,
  46. "alcohol": 9
  47. }
  48. }
  49. TARGET_range = {
  50. "min": 3.0,
  51. "max": 8.0
  52. }
  53. def test_form_response_correct_range(data=input_data["correct_range"]):
  54. res = form_response(data)
  55. assert TARGET_range["min"] <= res <= TARGET_range["max"]
  56. def test_api_response_correct_range(data=input_data["correct_range"]):
  57. res = api_response(data)
  58. assert TARGET_range["min"] <= res["response"] <= TARGET_range["max"]
  59. def test_form_response_incorrect_range(data=input_data["incorrect_range"]):
  60. with pytest.raises(prediction_service.prediction.NotInRange):
  61. res = form_response(data)
  62. def test_api_response_incorrect_range(data=input_data["incorrect_range"]):
  63. res = api_response(data)
  64. assert res["response"] == prediction_service.prediction.NotInRange().message
  65. def test_api_response_incorrect_col(data=input_data["incorrect_col"]):
  66. res = api_response(data)
  67. assert res["response"] == prediction_service.prediction.NotInCols().message
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...