Skip to content

Commit f2af923

Browse files
Merge pull request #13 from VikingInOrbit/UnitTest
Unit test
2 parents 05c265d + b01d6fd commit f2af923

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1809
-53
lines changed

.coverage

148 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ secrets/*
88
!secrets/.gitkeep
99
temp/
1010
log/
11-
.vscode
11+
12+
.vscode
13+
.coverage

ChangeLog.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,74 @@
11
# Updates
22

3+
## 1.9.2 get to 90% update
4+
5+
### new things
6+
7+
- Suproting 100%
8+
9+
- Utility 99%
10+
- collor 100%
11+
- deltatime 98%
12+
- UnitConverter 100%
13+
- config manager 100%
14+
- logger 100%
15+
- debug 97%
16+
17+
- Data Prosesing 52%
18+
- csv data pipeline 100%
19+
- filter 96%
20+
- map 91%
21+
- PID 98%
22+
- data swite will not be tested at this moment
23+
24+
- contol softwere
25+
- State machine
26+
- will not be tested at this moment
27+
28+
### bug Fix
29+
30+
- somthing
31+
32+
### changes
33+
34+
- somthing
35+
36+
### breaking changes
37+
38+
- somthing
39+
40+
## 1.9.1 location update
41+
42+
### new things
43+
44+
- Base Unit test
45+
- 100% suporting
46+
47+
### breaking changes
48+
49+
- file structure
50+
51+
## 1.9.0 Test update
52+
53+
### new things
54+
55+
- Unit test
56+
- UnitTestUtilities.py
57+
58+
### bug Fix
59+
60+
- somthing
61+
62+
### changes
63+
64+
- yamlWriter now suports mode=a the right way
65+
- Exsamlpe files now change name to exsample and not test
66+
- all suporting script tests uptated to use the test util
67+
68+
### breaking changes
69+
70+
- Exsample is no longer the main way of testing the code
71+
372
## 1.8.2 csv update
473

574

DataProsesing/DataRW.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
from ..Suporting.jsonWriter import *
88
from ..Suporting.yamlWriter import *
99

10-
#from ..Utility.Debug import Debug
10+
from ..Utility.Debug import Debug
1111

1212

1313
def write_data(file_path,data, **kwargs):
1414

1515
directory = os.path.dirname(file_path)
1616
if directory and not os.path.exists(directory):
1717
os.makedirs(directory, exist_ok=True)
18-
#Debug.log(f"Dir did not exist, created it: {directory}", "Warning", group="WarningError")
18+
Debug.log(f"Dir did not exist, created it: {directory}", "Warning", group="WarningError")
1919

2020
ext = os.path.splitext(file_path)[1].lower()
2121

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ using "import GabesPythonToolBox as GTB" for all
1616
or import "GabesPythonToolBox.Category.lib as (XX)"
1717
That’s it. You're good to go.
1818

19+
### comands
20+
#### unit test
21+
'''
22+
pytest UnitTest -v
23+
'''
24+
#### get filestucture
25+
'''
26+
tree /F /A > folder_tree.txt
27+
'''
28+
1929
## Current Features
2030

2131
### ControllSoftwere

Suporting/csvReader.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def read_csv(file_path, seperator_symbol: str = ',', float_symbol: str = '.', re
7373
# Process each line using the helper
7474
for line in lines:
7575
values = process_line(line, seperator_symbol, float_symbol)
76+
if not values:
77+
Debug.log(f"emty row","Info",group="LIB_Debug")
78+
continue # skip empty lines
7679
row = {header[i]: values[i] for i in range(len(header))}
7780
Debug.log(f"row:\n{row}\n\n","Info",group="LIB_Debug")
7881
data.append(row)

Suporting/csvWriterLogger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import copy
33
import csv
4-
4+
#TODO make it one file again
55
#this is a direct coppy of csvWriter and oly exsists sice circular import isues
66

77
def write_csv(

Suporting/jsonWriter.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
import json
2-
def write_json(file_path,data,mode: str = 'w'):
2+
import os
3+
4+
def write_json(file_path, data, mode: str = 'w'):
5+
"""
6+
Write a dictionary to a JSON file.
7+
If mode='a', merge with existing JSON content if it is a dict.
8+
"""
9+
if mode == 'a' and os.path.exists(file_path):
10+
# Load existing data
11+
with open(file_path, "r", encoding="utf-8") as f:
12+
try:
13+
existing_data = json.load(f)
14+
except json.JSONDecodeError:
15+
raise ValueError("Existing JSON content is invalid")
16+
if not isinstance(existing_data, dict):
17+
raise TypeError("Existing JSON content is not a dict; cannot merge")
18+
19+
# Merge existing data with new data
20+
existing_data.update(data)
21+
data_to_write = existing_data
22+
mode = 'w' # overwrite with merged content
23+
else:
24+
data_to_write = data
25+
326
with open(file_path, mode=mode, encoding="utf-8") as f:
4-
json.dump(data, f, indent=4, ensure_ascii=False)
27+
json.dump(data_to_write, f, indent=4, ensure_ascii=False)

Suporting/yamlWriter.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
import yaml
2-
def write_yaml(file_path,data,mode: str = 'w'):
3-
with open(file_path,mode=mode, encoding="utf-8") as f:
4-
yaml.safe_dump(data, f, sort_keys=False, allow_unicode=True)
2+
import os
3+
4+
def write_yaml(file_path, data, mode: str = 'w'):
5+
"""
6+
Write a dictionary to a YAML file.
7+
If mode='a', merge with existing YAML content if it is a dict.
8+
"""
9+
if mode == 'a' and os.path.exists(file_path):
10+
# Load existing data
11+
with open(file_path, "r", encoding="utf-8") as f:
12+
existing_data = yaml.safe_load(f) or {}
13+
if not isinstance(existing_data, dict):
14+
raise TypeError("Existing YAML content is not a dict; cannot merge")
15+
16+
# Merge existing data with new data
17+
existing_data.update(data)
18+
data_to_write = existing_data
19+
mode = 'w' # Overwrite file with merged content
20+
else:
21+
data_to_write = data
22+
23+
with open(file_path, mode=mode, encoding="utf-8") as f:
24+
yaml.safe_dump(data_to_write, f, sort_keys=False, allow_unicode=True)

Tests/FallbackTest/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)