Codium-ai / codiumai-vscode-release

258 stars 34 forks source link

No generated tests, please try again #169

Open StefanIgnjatovic12 opened 3 weeks ago

StefanIgnjatovic12 commented 3 weeks ago

Hi,

I am constantly getting this. Sometimes the tests get generated but it's like 1/10 times. I'm using pytest and when I try to generate the tests for the class it never works at all. Clicking regenerate tests results in the same error. I have fiddled with the number of tests setting in the config, removing the example test etc but it makes no difference. Here is the output from the output tab including the contents of the config toml

["DEBUG" - 3:42:53 PM] [CONFIG] Reading config, starting from directory
{
  "currentDir": "c:_\\_\\fetching_pipeline_orchestration",
  "currDirResolved": "c:_\\_\\fetching_pipeline_orchestration"
}
["DEBUG" - 3:42:53 PM] [CONFIG] Discovered and parsed config file
{
  "codiumFile": "c:_\\_\\.codiumai.toml",
  "parsedConfig": {
    "tests": {
      "type": "section",
      "filePath": "c:_\\_\\.codiumai.toml",
      "entries": {
        "framework": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": "Pytest"
        },
        "use_mocks": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": true
        },
        "num_desired_tests": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": 6
        },
        "plan_instructions": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": "1. Use MagicMock when possible\r\n2. Use \"Arrange, Act, Assert\" style\r\n3. Use pytest fixtures\r\n4. Use patching where required\r\n"
        },
        "example_test": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": "def test_process_item_success(processor, mock_item_data, mocker):\r\n    # Mock the item_model_class and its method\r\n    mock_model_instance = MagicMock()\r\n    mock_model_class = MagicMock(return_value=mock_model_instance)\r\n    mock_model_class.__name__ = 'MockModel'\r\n    processor.item_model_class = mock_model_class\r\n    \r\n    # Execute\r\n    result = processor.process_item(mock_item_data)\r\n    \r\n    # Assert\r\n    assert result is not None\r\n    assert result.item_type == 'MockModel'\r\n    assert result.model == mock_model_instance\r\n"
        },
        "javascript": {
          "type": "section",
          "filePath": "c:_\\_\\.codiumai.toml",
          "entries": {}
        }
      }
    }
  }
}
["DEBUG" - 3:42:53 PM] generate tests action triggered
{
  "requestId": "63f989d0-e4e9-458e-8f1a-ce4b1fa9a937",
  "language": "python",
  "componentType": "class",
  "componentName": "CNMarketAPIResponseProcessor",
  "isConfigurationFileExist": true,
  "invocationType": "button"
}
["DEBUG" - 3:42:54 PM] [CONFIG] Reading config, starting from directory
{
  "currentDir": "c:_\\_\\fetching_pipeline_orchestration",
  "currDirResolved": "c:_\\_\\fetching_pipeline_orchestration"
}
["DEBUG" - 3:42:54 PM] [CONFIG] Discovered and parsed config file
{
  "codiumFile": "c:_\\_\\.codiumai.toml",
  "parsedConfig": {
    "tests": {
      "type": "section",
      "filePath": "c:_\\_\\.codiumai.toml",
      "entries": {
        "framework": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": "Pytest"
        },
        "use_mocks": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": true
        },
        "num_desired_tests": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": 6
        },
        "plan_instructions": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": "1. Use MagicMock when possible\r\n2. Use \"Arrange, Act, Assert\" style\r\n3. Use pytest fixtures\r\n4. Use patching where required\r\n"
        },
        "example_test": {
          "type": "value",
          "filePath": "c:_\\_\\.codiumai.toml",
          "value": "def test_process_item_success(processor, mock_item_data, mocker):\r\n    # Mock the item_model_class and its method\r\n    mock_model_instance = MagicMock()\r\n    mock_model_class = MagicMock(return_value=mock_model_instance)\r\n    mock_model_class.__name__ = 'MockModel'\r\n    processor.item_model_class = mock_model_class\r\n    \r\n    # Execute\r\n    result = processor.process_item(mock_item_data)\r\n    \r\n    # Assert\r\n    assert result is not None\r\n    assert result.item_type == 'MockModel'\r\n    assert result.model == mock_model_instance\r\n"
        },
        "javascript": {
          "type": "section",
          "filePath": "c:_\\_\\.codiumai.toml",
          "entries": {}
        }
      }
    }
  }
}
["DEBUG" - 3:42:55 PM] http request sent
{
  "requestId": "63f989d0-e4e9-458e-8f1a-ce4b1fa9a937:7da58c08-4654-41b1-82f7-8342b6f289fd",
  "action": "generateTests",
  "panelId": "/c:/_/_/fetching_pipeline_orchestration/api_response_processor.py_CNMarketAPIResponseProcessor_63f989d0-e4e9-458e-8f1a-ce4b1fa9a937",
  "previousRequestId": "63f989d0-e4e9-458e-8f1a-ce4b1fa9a937",
  "configuration": {
    "reference_test": "def test_process_item_success(processor, mock_item_data, mocker):\r\n    # Mock the item_model_class and its method\r\n    mock_model_instance = MagicMock()\r\n    mock_model_class = MagicMock(return_value=mock_model_instance)\r\n    mock_model_class.__name__ = 'MockModel'\r\n    processor.item_model_class = mock_model_class\r\n    \r\n    # Execute\r\n    result = processor.process_item(mock_item_data)\r\n    \r\n    # Assert\r\n    assert result is not None\r\n    assert result.item_type == 'MockModel'\r\n    assert result.model == mock_model_instance\r\n",
    "framework": "Pytest",
    "plan_instructions": "1. Use MagicMock when possible\r\n2. Use \"Arrange, Act, Assert\" style\r\n3. Use pytest fixtures\r\n4. Use patching where required\r\n",
    "num_desired_tests": 6,
    "is_add_test_to_suite": false
  },
  "regenerate_tests": false,
  "generate_suggestions": false,
  "should_return_context": false
}
["DEBUG" - 3:45:36 PM] panel closed
["DEBUG" - 3:45:37 PM] panel closed
oranshiner commented 1 week ago

Hi Stefan,

Thank you for reporting this issue, we would take a look and let you know when it would be fixed