gperdrizet commited on
Commit
9ba8701
·
verified ·
1 Parent(s): 7e01b9e

Updated tests to reflect new job call loading logic

Browse files
Files changed (1) hide show
  1. tests/test_gradio.py +48 -4
tests/test_gradio.py CHANGED
@@ -10,8 +10,11 @@ from functions import gradio
10
  class TestProcessInputs(unittest.TestCase):
11
  """Test cases for the process_inputs function."""
12
 
13
- def test_no_inputs_provided(self):
14
- """Test when no inputs are provided."""
 
 
 
15
 
16
  with patch('functions.gradio.get_github_repositories') as mock_github:
17
  mock_github.return_value = {"status": "success", "metadata": {"username": "gperdrizet"}}
@@ -25,6 +28,25 @@ class TestProcessInputs(unittest.TestCase):
25
  self.assertIn("ℹ️ No additional instructions provided", result)
26
  self.assertIn("❌ Cannot generate resume: No valid LinkedIn data extracted", result)
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  def test_all_inputs_provided_success(self):
29
  """Test when all inputs are provided and successful."""
30
 
@@ -151,8 +173,11 @@ class TestProcessInputs(unittest.TestCase):
151
  # Verify write_resume was NOT called since no LinkedIn data
152
  mock_write_resume.assert_not_called()
153
 
154
- def test_whitespace_only_inputs(self):
155
- """Test inputs with only whitespace."""
 
 
 
156
 
157
  with patch('functions.gradio.get_github_repositories') as mock_github:
158
  mock_github.return_value = {"status": "success", "metadata": {"username": "gperdrizet"}}
@@ -166,6 +191,25 @@ class TestProcessInputs(unittest.TestCase):
166
  self.assertIn("ℹ️ No additional instructions provided", result)
167
  self.assertIn("❌ Cannot generate resume: No valid LinkedIn data extracted", result)
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  @patch('functions.gradio.write_resume')
170
  @patch('functions.gradio.summarize_job_call')
171
  def test_job_post_with_content(self, mock_summarize, mock_write_resume):
 
10
  class TestProcessInputs(unittest.TestCase):
11
  """Test cases for the process_inputs function."""
12
 
13
+ @patch('functions.gradio.load_default_job_call')
14
+ def test_no_inputs_provided(self, mock_load_default):
15
+ """Test when no inputs are provided and default job is available."""
16
+ # Mock default job call loading to return content
17
+ mock_load_default.return_value = "Default job content from sample_job.txt"
18
 
19
  with patch('functions.gradio.get_github_repositories') as mock_github:
20
  mock_github.return_value = {"status": "success", "metadata": {"username": "gperdrizet"}}
 
28
  self.assertIn("ℹ️ No additional instructions provided", result)
29
  self.assertIn("❌ Cannot generate resume: No valid LinkedIn data extracted", result)
30
 
31
+ @patch('functions.gradio.load_default_job_call')
32
+ def test_no_inputs_no_default_job(self, mock_load_default):
33
+ """Test when no inputs are provided and no default job is available."""
34
+ # Mock default job call loading to return None (no default available)
35
+ mock_load_default.return_value = None
36
+
37
+ with patch('functions.gradio.get_github_repositories') as mock_github:
38
+ mock_github.return_value = {"status": "success", "metadata": {"username": "gperdrizet"}}
39
+
40
+ result = gradio.process_inputs(None, "", "", "")
41
+
42
+ self.assertIn("❌ No LinkedIn resume PDF file uploaded", result)
43
+ self.assertIn("✅ Using default GitHub Profile URL", result)
44
+ self.assertIn("ℹ️ No job post provided, attempting to use default", result)
45
+ self.assertIn("ℹ️ No default job post available, proceeding without job post", result)
46
+ self.assertIn("ℹ️ Proceeding without job post analysis", result)
47
+ self.assertIn("ℹ️ No additional instructions provided", result)
48
+ self.assertIn("❌ Cannot generate resume: No valid LinkedIn data extracted", result)
49
+
50
  def test_all_inputs_provided_success(self):
51
  """Test when all inputs are provided and successful."""
52
 
 
173
  # Verify write_resume was NOT called since no LinkedIn data
174
  mock_write_resume.assert_not_called()
175
 
176
+ @patch('functions.gradio.load_default_job_call')
177
+ def test_whitespace_only_inputs(self, mock_load_default):
178
+ """Test inputs with only whitespace and default job available."""
179
+ # Mock default job call loading to return content
180
+ mock_load_default.return_value = "Default job content from sample_job.txt"
181
 
182
  with patch('functions.gradio.get_github_repositories') as mock_github:
183
  mock_github.return_value = {"status": "success", "metadata": {"username": "gperdrizet"}}
 
191
  self.assertIn("ℹ️ No additional instructions provided", result)
192
  self.assertIn("❌ Cannot generate resume: No valid LinkedIn data extracted", result)
193
 
194
+ @patch('functions.gradio.load_default_job_call')
195
+ def test_whitespace_only_inputs_no_default(self, mock_load_default):
196
+ """Test inputs with only whitespace and no default job available."""
197
+ # Mock default job call loading to return None
198
+ mock_load_default.return_value = None
199
+
200
+ with patch('functions.gradio.get_github_repositories') as mock_github:
201
+ mock_github.return_value = {"status": "success", "metadata": {"username": "gperdrizet"}}
202
+
203
+ result = gradio.process_inputs(None, " ", " ", " ")
204
+
205
+ self.assertIn("❌ No LinkedIn resume PDF file uploaded", result)
206
+ self.assertIn("✅ Using default GitHub Profile URL", result)
207
+ self.assertIn("ℹ️ No job post provided, attempting to use default", result)
208
+ self.assertIn("ℹ️ No default job post available, proceeding without job post", result)
209
+ self.assertIn("ℹ️ Proceeding without job post analysis", result)
210
+ self.assertIn("ℹ️ No additional instructions provided", result)
211
+ self.assertIn("❌ Cannot generate resume: No valid LinkedIn data extracted", result)
212
+
213
  @patch('functions.gradio.write_resume')
214
  @patch('functions.gradio.summarize_job_call')
215
  def test_job_post_with_content(self, mock_summarize, mock_write_resume):