Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] cetmix_tower_server: Server creation #183

Open
wants to merge 3 commits into
base: 14.0-dev
Choose a base branch
from

Conversation

GabbasovDinar
Copy link
Contributor

@GabbasovDinar GabbasovDinar commented Jan 15, 2025

  • Fix incorrect creation of server variables when generating a server from a template.
  • Enable the creation of servers from a template with either a full copy of variables or only the specified ones.
  • Allow the creation of servers with specific variable options.
  • Optimize search of existing variables and creation of new ones

Task: 4253

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced server creation functionality with the option to include existing template variables.
    • Introduced new mapping for configuration variable options.
    • Added a new test to verify server creation with partial variable removal.
  • Refactor

    • Restructured how server parameters are prepared for creation.
    • Simplified the handling of template variable options during server creation.
  • Bug Fixes

    • Improved validation and error handling for missing required configuration variables.
  • Documentation

    • Updated documentation to include examples for new configuration variable options.

Copy link

coderabbitai bot commented Jan 15, 2025

Walkthrough

The pull request introduces modifications to the CxTowerServerTemplate and CxTowerServerTemplateCreateWizard classes. Key changes include the addition of a boolean parameter pick_all_template_variables to several methods in the server template class, enhancing server creation functionality. The wizard class has been updated to include a new mapping for configuration variable options and to streamline data processing during server creation. Additionally, documentation has been updated to reflect these changes.

Changes

File Change Summary
cetmix_tower_server/models/cx_tower_server_template.py - Updated method signatures for create_server_from_template, _create_new_server, and _prepare_server_values to include pick_all_template_variables.
- Simplified variable value handling in _prepare_server_values based on the new parameter.
cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py - Added configuration_variable_options to the return value of _prepare_server_parameters.
- Removed construction of kwargs["line_ids_variables"] in action_confirm.
- Updated _create_new_server call to include pick_all_template_variables=False.
cetmix_tower_server/readme/USAGE.md - Updated create_server_from_template method signature to include configuration_variable_options.
- Minor formatting adjustments for clarity.
cetmix_tower_server/tests/test_server_template.py - Added new test method test_with_partial_removed_variables_from_wizard.
- Modified existing test test_create_server_from_template_action to accommodate new variable option logic.

Possibly related PRs

  • [FIX] cetmix_tower_server: enforce required variable validation #167: The changes in this PR enhance the _create_new_server and _validate_required_variables methods in the CxTowerServerTemplate class, which are directly related to the modifications made in the main PR regarding server creation and validation of required variables.
  • [14.0][IMP] cetmix-tower-server: Variable options improvements #179: This PR introduces a new field value_char in the cx.tower.variable.option model and updates various views, which aligns with the main PR's focus on enhancing server creation methods and handling variable values, particularly with the introduction of the pick_all_template_variables parameter.

Suggested labels

approved, ready to merge

Suggested reviewers

  • Aldeigja
  • ivs-cetmix

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 016312e and 042d18f.

📒 Files selected for processing (2)
  • cetmix_tower_server/models/cx_tower_server_template.py (5 hunks)
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py
  • cetmix_tower_server/models/cx_tower_server_template.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test with OCB

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cetmix_tower_server/models/cx_tower_server_template.py (1)

329-331: Consider adding validation for option_id consistency.

While the option handling is correct, consider validating that the option_id belongs to the variable to prevent potential mismatches.

 variable_option_id = configuration_variable_options.get(
     variable_reference
 )
+if variable_option_id:
+    option = self.env['cx.tower.variable.option'].browse(variable_option_id)
+    if option.variable_id != variable.id:
+        raise ValidationError(_(
+            "Invalid option selected for variable %(var)s",
+            var=variable_reference
+        ))
 variable_vals_list.append(
     (
         0,
         0,
         {
             "variable_id": variable.id,
             "value_char": variable_value,
             "option_id": variable_option_id,
         },
     )
 )

Also applies to: 337-340

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1e01f1 and 46741af.

📒 Files selected for processing (2)
  • cetmix_tower_server/models/cx_tower_server_template.py (2 hunks)
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (1 hunks)
🧰 Additional context used
📓 Learnings (1)
cetmix_tower_server/models/cx_tower_server_template.py (2)
Learnt from: tendil
PR: cetmix/cetmix-tower#167
File: cetmix_tower_server/models/cx_tower_server_template.py:0-0
Timestamp: 2024-12-31T11:16:47.023Z
Learning: The `_validate_required_variables` method in `cx_tower_server_template.py` now preserves the original order of required variables in its error messages by using a list instead of sorting, ensuring that tests and user-facing messages align with expectations.
Learnt from: tendil
PR: cetmix/cetmix-tower#154
File: cetmix_tower_server/models/cx_tower_server_template.py:204-233
Timestamp: 2024-12-02T10:09:44.153Z
Learning: In `cetmix_tower_server/models/cx_tower_server_template.py`, avoid adding validation logic in data normalization methods like `_create_new_server`; validation for required variables should be performed at the model level or in business logic methods to prevent duplication and maintain architectural cleanliness.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test with OCB
🔇 Additional comments (3)
cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (1)

113-117: LGTM! Verify option mapping in integration tests.

The addition of configuration_variable_options correctly maps variable references to their option IDs, fixing the server variable creation issue.

Run this script to verify the variable option mapping implementation:

✅ Verification successful

Implementation is well-tested ✓

The variable option mapping is verified through comprehensive test coverage:

  • Variable-option integration in test_variable_option.py
  • Server template variable handling in test_server_template.py
  • Variable value operations in test_variable.py
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for test coverage of the new configuration_variable_options mapping
rg -l "configuration_variable_options.*test" | while read -r file; do
  echo "=== $file ==="
  rg -A 5 "configuration_variable_options" "$file"
done

Length of output: 61


Script:

#!/bin/bash
# Find all test files and their content related to server templates and variables
echo "=== Finding test files ==="
fd "test.*\.py$"

echo -e "\n=== Searching for server template tests ==="
rg -l "class.*Server.*Test|class.*Template.*Test" -t py

echo -e "\n=== Checking test content for variable and option testing ==="
rg "def test.*(?i)(variable|option|server|template)" -t py -A 5

Length of output: 33173

cetmix_tower_server/models/cx_tower_server_template.py (2)

304-306: LGTM! Clean extraction of configuration options.

The extraction of configuration_variable_options is properly placed before variable processing.


344-344: Verify the impact on existing variable values.

The direct assignment to variable_value_ids replaces all existing values. Ensure this is the intended behavior.

✅ Verification successful

Direct assignment of variable values is the intended behavior

The codebase shows that variable values are designed to be fully manageable, with tests explicitly demonstrating removal and addition of values. The UI supports direct editing, and the One2many field type is consistently used across models for this purpose.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any places in the codebase that expect variable values to be preserved
rg -A 3 "variable_value_ids.*append" 

Length of output: 38


Script:

#!/bin/bash
# Search for variable_value_ids modifications and context
rg -B 2 -A 2 "variable_value_ids.*=" 

# Look for documentation about variable values
fd README -e md -x cat {} 

# Check for write operations using AST
ast-grep --pattern 'variable_value_ids = $_'

Length of output: 10777

@GabbasovDinar GabbasovDinar force-pushed the 14.0-t4253-cetmix_tower_server-fix-copy-from-template branch 2 times, most recently from b880fd7 to 0bb04e1 Compare January 15, 2025 08:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cetmix_tower_server/models/cx_tower_server_template.py (1)

356-377: Consider extracting variable update logic into a separate method.

While the implementation is correct, extracting the variable update logic into a separate method would improve maintainability and readability.

 def _prepare_server_values(self, with_template_variables=True, **kwargs):
     # ... existing code ...

     if configuration_variables:
         variable_vals_list = self._prepare_variable_values(
             configuration_variables,
             configuration_variable_options
         )
         if with_template_variables:
             values["variable_value_ids"] = self._update_existing_variables(
                 values.get("variable_value_ids", []),
                 variable_vals_list
             )
         else:
             values["variable_value_ids"] = variable_vals_list

+def _prepare_variable_values(self, configuration_variables, configuration_variable_options):
+    variable_vals_list = []
+    variable_obj = self.env["cx.tower.variable"]
+    
+    for variable_reference, variable_value in configuration_variables.items():
+        variable = variable_obj.search([("reference", "=", variable_reference)])
+        if not variable:
+            variable = variable_obj.create({"name": variable_reference})
+        
+        variable_option_id = configuration_variable_options.get(variable_reference)
+        variable_vals_list.append(
+            (0, 0, {
+                "variable_id": variable.id,
+                "value_char": variable_value,
+                "option_id": variable_option_id,
+            })
+        )
+    return variable_vals_list
+
+def _update_existing_variables(self, existing_variable_values, new_variable_vals):
+    variable_id_to_index = {
+        cmd[2]["variable_id"]: idx
+        for idx, cmd in enumerate(existing_variable_values)
+        if cmd[0] == 0 and "variable_id" in cmd[2]
+    }
+
+    for new_command in new_variable_vals:
+        variable_id = new_command[2]["variable_id"]
+        if variable_id in variable_id_to_index:
+            idx = variable_id_to_index[variable_id]
+            existing_variable_values[idx] = new_command
+        else:
+            existing_variable_values.append(new_command)
+
+    return existing_variable_values
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b880fd7 and 0bb04e1.

📒 Files selected for processing (2)
  • cetmix_tower_server/models/cx_tower_server_template.py (6 hunks)
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test with OCB
🔇 Additional comments (5)
cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (2)

113-117: LGTM! Clean implementation of configuration variable options.

The addition of configuration_variable_options properly maps variable references to their corresponding option IDs, aligning with the template class changes.


132-134: LGTM! Proper handling of template variables.

Setting with_template_variables=False ensures that only wizard-provided variables are used, preventing potential variable duplication or conflicts.

cetmix_tower_server/models/cx_tower_server_template.py (3)

174-177: LGTM! Well-documented parameter.

The documentation for with_template_variables clearly explains its purpose, behavior, and default value.


262-262: LGTM! Consistent parameter implementation.

The with_template_variables parameter is properly added to the method signature with consistent documentation.

Also applies to: 271-274


316-318: LGTM! Well-structured variable options handling.

The implementation properly extracts, looks up, and applies variable options during server creation.

Also applies to: 341-343, 349-351

@GabbasovDinar GabbasovDinar force-pushed the 14.0-t4253-cetmix_tower_server-fix-copy-from-template branch from 0bb04e1 to d2b957d Compare January 15, 2025 11:37
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cetmix_tower_server/models/cx_tower_server_template.py (1)

314-346: Consider reordering validation checks for better UX.

Currently, required variables are validated before checking if options exist. Consider reordering these checks to validate options first, providing a better user experience by showing the most relevant error message first.

     if configuration_variables:
-        # Validate required variables
-        self._validate_required_variables(configuration_variables)
-
         # Search for existing variable options.
         option_references = list(configuration_variable_options.values())
         existing_options = option_references and self.env[
             "cx.tower.variable.option"
         ].search([("reference", "in", option_references)])
         missing_options = list(
             set(option_references)
             - {option.reference for option in existing_options}
         )
         if missing_options:
             raise UserError(
                 _(
                     "Option with references '%(references)s' "
                     "is not found for variables.",
                     references=", ".join(missing_options),
                 )
             )

+        # Validate required variables after options are validated
+        self._validate_required_variables(configuration_variables)
+
         # Map variable options to their IDs.
         configuration_variable_options_dict = {
             option.variable_id.id: option.id for option in existing_options
         }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bb04e1 and d2b957d.

📒 Files selected for processing (2)
  • cetmix_tower_server/models/cx_tower_server_template.py (6 hunks)
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test with OCB
🔇 Additional comments (4)
cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (2)

113-117: LGTM! Configuration variable options mapping added.

The addition of configuration_variable_options correctly maps variable references to their option references, aligning with the template class changes.


132-134: LGTM! Server creation now correctly handles template variables.

Setting with_template_variables=False ensures that only the variables from the wizard are used, preventing duplication with template variables.

cetmix_tower_server/models/cx_tower_server_template.py (2)

174-177: LGTM! Well-documented parameter addition.

The documentation for the with_template_variables parameter is clear, consistent, and explains the behavior well across all methods.

Also applies to: 206-209, 271-274


388-409: LGTM! Robust handling of template variables.

The conditional handling of variable values based on with_template_variables is well-implemented:

  • When True: Updates or adds variable values from the template
  • When False: Uses only the new variable values

@GabbasovDinar GabbasovDinar force-pushed the 14.0-t4253-cetmix_tower_server-fix-copy-from-template branch 4 times, most recently from d454653 to 3a0d0a3 Compare January 15, 2025 13:45
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 1

🧹 Nitpick comments (1)
cetmix_tower_server/models/cx_tower_server_template.py (1)

316-341: Enhance error handling for variable options.

The validation of variable options is thorough, but the error message could be more specific.

Consider this improvement:

-                            "Option with references '%(references)s' "
-                            "is not found for variables.",
+                            "Variable options with references '%(references)s' "
+                            "were not found in the system. Please ensure all referenced options exist.",
🛑 Comments failed to post (1)
cetmix_tower_server/tests/test_server_template.py (1)

809-809: ⚠️ Potential issue

Fix code formatting issue.

There's a code formatting issue detected by ruff-format.

Add a newline at line 809 to fix the formatting issue.

🧰 Tools
🪛 GitHub Actions: pre-commit

[error] 809-809: Code formatting issue detected by ruff-format

@GabbasovDinar GabbasovDinar force-pushed the 14.0-t4253-cetmix_tower_server-fix-copy-from-template branch from 3a0d0a3 to d9ed258 Compare January 15, 2025 13:49
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cetmix_tower_server/models/cx_tower_server_template.py (1)

391-427: Consider adding error handling for duplicate variables.

The variable values handling is well-structured, but there's no explicit handling for potential duplicate variables when merging template and configuration variables.

Consider adding validation to ensure no duplicate variable IDs exist when merging:

 if with_template_variables:
+    # Check for duplicates in existing variables
+    existing_variable_ids = set()
+    for cmd in existing_variable_values:
+        if cmd[0] == 0 and "variable_id" in cmd[2]:
+            if cmd[2]["variable_id"] in existing_variable_ids:
+                raise ValidationError(_("Duplicate variable found in template"))
+            existing_variable_ids.add(cmd[2]["variable_id"])
+
     # update or add variable values
     existing_variable_values = values.get("variable_value_ids", [])
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d454653 and d9ed258.

📒 Files selected for processing (4)
  • cetmix_tower_server/models/cx_tower_server_template.py (6 hunks)
  • cetmix_tower_server/readme/USAGE.md (3 hunks)
  • cetmix_tower_server/tests/test_server_template.py (4 hunks)
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • cetmix_tower_server/readme/USAGE.md
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py
🔇 Additional comments (5)
cetmix_tower_server/models/cx_tower_server_template.py (4)

174-177: LGTM! Well-documented parameter.

The docstring for with_template_variables is clear and comprehensive.


271-274: LGTM! Consistent documentation.

The docstring for with_template_variables matches the parent function's documentation.


314-318: LGTM! Clean configuration handling.

The configuration variable options are properly extracted from kwargs.


324-346: LGTM! Robust validation.

The validation of variable options is thorough with:

  • Proper error handling for missing options
  • Clear error messages
  • Efficient mapping of options to their IDs
cetmix_tower_server/tests/test_server_template.py (1)

813-878: LGTM! Comprehensive test coverage.

The test thoroughly validates the partial variable removal scenario:

  • Creates variable option with test data
  • Sets up template with multiple variables
  • Simulates user interaction through wizard
  • Verifies both count and content of variables

- Fix incorrect creation of server variables when generating a server from a template.
- Enable the creation of servers from a template with either a full copy of variables or only the specified ones.
- Allow the creation of servers with specific variable options.
- Optimize search of existing variables and creation of new ones

Task: 4253
@GabbasovDinar GabbasovDinar force-pushed the 14.0-t4253-cetmix_tower_server-fix-copy-from-template branch from d9ed258 to 5da7233 Compare January 16, 2025 06:20
- Improve validation error message

Task: 4253
@GabbasovDinar GabbasovDinar force-pushed the 14.0-t4253-cetmix_tower_server-fix-copy-from-template branch from 5da7233 to 016312e Compare January 16, 2025 06:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cetmix_tower_server/tests/test_server_template.py (1)

864-866: Consider enhancing the test robustness.

  1. The magic number 0 in remove(0) makes the test fragile. Consider finding the line by variable reference instead.
  2. Add assertions to verify that the removed variable is actually gone.
  3. Consider adding negative test cases (e.g., removing required variables).
-            wizard_form.line_ids.remove(0)
+            # Find and remove the line with variable_path
+            for index, line in enumerate(wizard_form.line_ids):
+                if line.variable_id == self.variable_path:
+                    wizard_form.line_ids.remove(index)
+                    break
             wizard_form.save()

+        # Verify that the removed variable is not present
+        self.assertFalse(
+            any(line.variable_id == self.variable_path for line in wizard.line_ids),
+            "Removed variable should not be present in the wizard",
+        )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9ed258 and 5da7233.

📒 Files selected for processing (4)
  • cetmix_tower_server/models/cx_tower_server_template.py (5 hunks)
  • cetmix_tower_server/readme/USAGE.md (3 hunks)
  • cetmix_tower_server/tests/test_server_template.py (4 hunks)
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • cetmix_tower_server/readme/USAGE.md
  • cetmix_tower_server/models/cx_tower_server_template.py
  • cetmix_tower_server/wizards/cx_tower_server_template_create_wizard.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test with OCB
🔇 Additional comments (2)
cetmix_tower_server/tests/test_server_template.py (2)

Line range hint 156-178: LGTM! Good enhancement to the test.

The addition of variable option testing improves the test coverage and makes the test more maintainable by using dynamic values instead of hardcoded strings.


813-878: LGTM! Well-structured test case.

The test effectively verifies the partial variable removal functionality with clear setup, actions, and assertions. Good use of Form to simulate UI interactions.

"Variable reference '%(var_ref)s' has an invalid "
"option reference '%(opt_ref)s'."
)
% {"var_ref": var_ref, "opt_ref": opt_ref}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use correct method for string translations.

cetmix_tower_server/models/cx_tower_server_template.py Outdated Show resolved Hide resolved
cetmix_tower_server/models/cx_tower_server_template.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Aldeigja Aldeigja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional LGTM

@@ -251,7 +259,7 @@ def _get_fields_tower_server(self):
"server_log_ids",
]

def _prepare_server_values(self, **kwargs):
def _prepare_server_values(self, pick_all_template_variables=True, **kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with these changes, prepare_server_values is not a bit long, should we refactor to make it shorter and easier to understand?

configuration_variables = kwargs.pop("configuration_variables", None)
line_ids_variables = kwargs.pop("line_ids_variables", None)
configuration_variable_options = kwargs.pop(
"configuration_variable_options", {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this one added to the docstring similar to how configuration_variables is, is it missed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants