Skip to content

Commit 25b7ef5

Browse files
committed
Addressing sonarqube errors and refactoring
1 parent 5b96482 commit 25b7ef5

File tree

1 file changed

+51
-27
lines changed

1 file changed

+51
-27
lines changed
Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,95 @@
11
# Utility Guide: fit_kit_generation
22

3-
The FitKitGeneration Utility provides methods to generate and manage FIT test kits for testing purposes.
3+
The fit_kit_generation Utility provides methods to generate and manage FIT test kits for testing purposes.
44

55
## Table of Contents
66

77
- [Utility Guide: fit\_kit\_generation](#utility-guide-fit_kit_generation)
88
- [Table of Contents](#table-of-contents)
9-
- [Using the FitKitGeneration Utility](#using-the-fitkitgeneration-utility)
9+
- [Using the fit\_kit\_generation Utility](#using-the-fit_kit_generation-utility)
1010
- [Required Arguments](#required-arguments)
11-
- [FitKitGeneration Specific Functions](#fitkitgeneration-specific-functions)
11+
- [fit\_kit\_generation Specific Functions](#fit_kit_generation-specific-functions)
12+
- [fit\_kit\_generation Specific Functions](#fit_kit_generation-specific-functions-1)
1213
- [Example Usage](#example-usage)
13-
- [Call the example usage function](#call-the-example-usage-function)
1414

15-
## Using the FitKitGeneration Utility
15+
## Using the fit_kit_generation Utility
1616

17-
To use the fit_kit_generation Utility, import the `fit_kit_generation` module, from the `utils` directory, into your test file and call it's methods from within your tests, as required.
17+
To use the fit_kit_generation Utility, import the `fit_kit_generation` module, from the `utils` directory, into your test file and call its methods from within your tests, as required.
1818

1919
## Required Arguments
2020

21-
The methods in this utility require specific arguments. Refer to the docstrings in the `fit_kit_generation.py` file for details on required and optional arguments.
21+
The methods in this utility require specific arguments. Below is a summary of the required arguments for key methods:
22+
- `generate_kit`: Requires `batch_id` (int) and `kit_type` (str).
23+
## fit_kit_generation Specific Functions
2224

23-
## FitKitGeneration Specific Functions
25+
The fit_kit_generation Utility includes methods for generating, validating, and managing FIT test kits. These methods are designed to streamline the process of creating test kits for various scenarios. Below are some key functions:
2426

25-
The FitKitGeneration Utility includes methods for generating, validating, and managing FIT test kits. These methods are designed to streamline the process of creating test kits for various scenarios. Below are some key functions:
27+
1. **`create_fit_id_df(tk_type_id: int, hub_id: int, no_of_kits: int) -> DataFrame`**
28+
Creates a DataFrame containing FIT kit IDs based on the provided parameters.
29+
- **Arguments**:
30+
- `tk_type_id` (int): The type ID of the test kit.
31+
- `hub_id` (int): The hub ID associated with the kits.
32+
- `no_of_kits` (int): The number of kits to retrieve.
33+
- **Returns**: A pandas DataFrame with the FIT kit IDs.
34+
35+
2. **`calculate_check_digit(kit_id: str) -> str`**
36+
Calculates and appends a check digit to the given kit ID.
37+
- **Arguments**:
38+
- `kit_id` (str): The kit ID to process.
39+
- **Returns**: The kit ID with the appended check digit.
40+
41+
3. **`convert_kit_id_to_fit_device_id(kit_id: str) -> str`**
42+
Converts a kit ID into a FIT Device ID.
43+
- **Arguments**:
44+
- `kit_id` (str): The kit ID to convert.
45+
- **Returns**: The corresponding FIT Device ID.
46+
47+
## fit_kit_generation Specific Functions
48+
49+
The fit_kit_generation Utility includes methods for generating, validating, and managing FIT test kits. These methods are designed to streamline the process of creating test kits for various scenarios. Below are some key functions:
2650

27-
1. **`generate_kit(batch_id: int, kit_type: str) -> dict`**
28-
Generates a FIT test kit with the specified batch ID and kit type.
51+
1. **`generate_kit(batch_id: int, kit_type: str) -> dict`**
52+
Generates a FIT test kit with the specified batch ID and kit type.
2953
- **Arguments**:
3054
- `batch_id` (int): The ID of the batch to which the kit belongs.
3155
- `kit_type` (str): The type of kit to generate (e.g., "Standard", "Advanced").
3256
- **Returns**: A dictionary containing the details of the generated kit.
3357

34-
2. **`validate_kit(kit_id: int) -> bool`**
35-
Validates a FIT test kit by its ID.
58+
2. **`validate_kit(kit_id: int) -> bool`**
59+
Validates a FIT test kit by its ID.
3660
- **Arguments**:
3761
- `kit_id` (int): The ID of the kit to validate.
3862
- **Returns**: `True` if the kit is valid, `False` otherwise.
3963

40-
3. **`manage_kits(action: str, kit_ids: list[int]) -> None`**
41-
Performs bulk actions on a list of FIT test kits.
64+
3. **`manage_kits(action: str, kit_ids: list[int]) -> None`**
65+
Performs bulk actions on a list of FIT test kits.
4266
- **Arguments**:
4367
- `action` (str): The action to perform (e.g., "activate", "deactivate").
4468
- `kit_ids` (list[int]): A list of kit IDs to apply the action to.
4569

4670
## Example Usage
4771

72+
```python
4873
from utils.fit_kit_generation import create_fit_id_df, calculate_check_digit, convert_kit_id_to_fit_device_id
4974

5075
def example_usage() -> None:
5176
# Example inputs
52-
tk_type_id = 1
53-
hub_id = 101
54-
no_of_kits_to_retrieve = 2
77+
tk_type_id = 1
78+
hub_id = 101
79+
no_of_kits_to_retrieve = 2
5580

5681
# Step 1: Retrieve and process FIT kit data
57-
fit_kit_df = create_fit_id_df(tk_type_id, hub_id, no_of_kits_to_retrieve)
58-
print("Processed FIT Kit DataFrame:")
59-
print(fit_kit_df)
82+
fit_kit_df = create_fit_id_df(tk_type_id, hub_id, no_of_kits_to_retrieve)
83+
print("Processed FIT Kit DataFrame:")
84+
print(fit_kit_df)
6085

6186
# Step 2: Calculate a check digit for a single kit ID
62-
kit_id = "ABC123"
63-
kit_with_check_digit = calculate_check_digit(kit_id)
64-
print(f"Kit ID with Check Digit: {kit_with_check_digit}")
87+
kit_id = "ABC123"
88+
kit_with_check_digit = calculate_check_digit(kit_id)
89+
print(f"Kit ID with Check Digit: {kit_with_check_digit}")
6590

6691
# Step 3: Convert a kit ID to a FIT Device ID
67-
fit_device_id = convert_kit_id_to_fit_device_id(kit_with_check_digit)
68-
print(f"FIT Device ID: {fit_device_id}")
92+
fit_device_id = convert_kit_id_to_fit_device_id(kit_with_check_digit)
93+
print(f"FIT Device ID: {fit_device_id}")
6994

70-
# Call the example usage function
7195
example_usage()

0 commit comments

Comments
 (0)