Skip to content

Commit

Permalink
Merge pull request #136 from MostHappyCougar/ready_to_test
Browse files Browse the repository at this point in the history
Update Utility Architecture
  • Loading branch information
MostHappyCougar authored Nov 24, 2023
2 parents b575614 + ed70b82 commit 074f2e4
Show file tree
Hide file tree
Showing 28 changed files with 35 additions and 101 deletions.
20 changes: 3 additions & 17 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>








<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>








<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>







<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}/code/test</path>
<path>/${PROJECT_DIR_NAME}/code/cov_tool</path>
</pydev_pathproperty>






Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ git clone https://github.com/MostHappyCougar/QACoverageTool.git
Or just download packages from last release

## Requirements
`requirements.txt` file is in code/python directory of this utility.
`requirements.txt` file is in code/cov_tool directory of this utility.
Change current work directory to `some/path/to/code/cov_tool` then execute in terminal to install requirements:
```
$ pip install -r requirements.txt
Expand All @@ -29,11 +29,11 @@ from any work directory

# Usage
## Configuration
Befure utility use you should create and configure a config in `/code/cov_tool/configurations/` directory. There is should be specified a list of analysis mods that will be performed at utility run. Also you can configure each analysis mod in details via mentioned config. There is possible to store several configs and use any count of them individually or together
Befure utility use you should create and configure a config in `/code/configurations/` directory. There is should be specified a list of analysis mods that will be performed at utility run. Also you can configure each analysis mod in details via mentioned config. There is possible to store several configs and use any count of them individually or together

<details><summary>Config Example</summary>

### This config is prepared for EXAMPLE.xlsx and 1_2_1_TEST.xlsx stored in `code/cov_tool/tables_to_analisys/`
### This config is prepared for EXAMPLE.xlsx and 1_2_1_TEST.xlsx stored in `code/tables_to_analisys/`

```yaml
##############################################
Expand Down Expand Up @@ -121,7 +121,7 @@ $ python cov_tool conf_default
#### Preconditions:
- Configuration:
Config file for this usage case is: `code/python/configurations/conf_default.yaml`
Config file for this usage case is: `code/configurations/conf_default.yaml`
- Input table for analysis - there is should be no merged cells:
Expand All @@ -131,7 +131,7 @@ $ python cov_tool conf_default
</details>
#### Analysis results:
- There is following files as result of analysis in `code/python/output/EXAMPLE`:
- There is following files as result of analysis in `code/output/EXAMPLE`:
<details><summary>EX_TEST.gv - dot-language file for state-transitions diagram</summary>
Expand Down Expand Up @@ -216,7 +216,7 @@ $ python cov_tool conf_default
#### Preconditions:
- Configuration:
Config file for this usage case is: `code/python/configurations/conf_default.yaml`
Config file for this usage case is: `code/configurations/conf_default.yaml`
- Input table for analysis - there is should be no merged cells:
Expand All @@ -227,7 +227,7 @@ $ python cov_tool conf_default
</details>
#### Analysis results:
- There is following files as result of analysis in `code/python/output/EXAMPLE`:
- There is following files as result of analysis in `code/output/EXAMPLE`:
<details><summary>EX_TEST_param_trace.xlsx</summary>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions code/cov_tool/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_conf_params(conf) -> dict:
#Perform analysis according to mods specified
for mod in np.unique(CONF_PARAMS["analysis-mods"]):
if mod == "state-transition":
path_to_input = os.path.join(os.path.dirname(__file__), CONF_PARAMS[mod]["input_directory"], CONF_PARAMS[mod]["input_table"])
path_to_input = os.path.join(os.path.dirname(__file__), "..", CONF_PARAMS[mod]["input_directory"], CONF_PARAMS[mod]["input_table"])

dataframe_to_analysis = DataFrameMakerXLSX(path_to_input, CONF_PARAMS[mod]["input_sheet"])
dataframe_to_analysis.pass_to_socket()
Expand All @@ -53,7 +53,7 @@ def get_conf_params(conf) -> dict:
OutputFactory.make_state_trans_output(analysis_results)

if mod == "parameters-traceability":
path_to_input = os.path.join(os.path.dirname(__file__), CONF_PARAMS[mod]["input_directory"], CONF_PARAMS[mod]["input_table"])
path_to_input = os.path.join(os.path.dirname(__file__), "..", CONF_PARAMS[mod]["input_directory"], CONF_PARAMS[mod]["input_table"])

dataframe_to_analysis = DataFrameMakerXLSX(path_to_input, CONF_PARAMS[mod]["input_sheet"])
dataframe_to_analysis.pass_to_socket()
Expand Down
2 changes: 1 addition & 1 deletion code/cov_tool/abstractions/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class IReadConfig(ABC):
'''

default_config = "conf_default"
default_path_to_configs = os.path.join(os.path.dirname(__file__), "..", "configurations")
default_path_to_configs = os.path.join(os.path.dirname(__file__), "..", "..", "configurations")


@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion code/cov_tool/abstractions/save_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ISaveOutput(ABC):
Interface that may be realized to save analysis results
'''

default_path_to_output = os.path.join(os.path.dirname(__file__), "..", "output")
default_path_to_output = os.path.join(os.path.dirname(__file__), "..", "..", "output")


@abstractmethod
Expand Down
53 changes: 0 additions & 53 deletions code/cov_tool/output/EXAMPLE/EX_TEST.gv

This file was deleted.

Binary file removed code/cov_tool/output/EXAMPLE/EX_TEST.gv.pdf
Binary file not shown.
Binary file not shown.
Binary file removed code/cov_tool/output/EXAMPLE/EX_TEST_path_stats.xlsx
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions code/cov_tool/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
contourpy==1.1.0
cycler==0.11.0
cycler==0.12.1
et-xmlfile==1.1.0
fonttools==4.42.1
graphviz==0.20.1
Jinja2==3.1.2
kiwisolver==1.4.5
MarkupSafe==2.1.3
matplotlib==3.7.2
numpy==1.25.2
numpy==1.26.0
openpyxl==3.1.2
packaging==23.1
pandas==2.0.3
Pillow==10.0.0
packaging==23.2
pandas==2.1.1
Pillow==10.0.1
pyparsing<3.1.0and>=2.3.1
python-dateutil==2.8.2
pytz==2023.3
Expand Down
File renamed without changes.
23 changes: 12 additions & 11 deletions code/test/test_1_analysis_mods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
There is code duplication because two different cases may be changed separately and irrespective to each other
'''


import os
import allure
import pytest
import sys
import codecs

from common_methods import user, files_processor
from common_methods import GLOBAL
Expand All @@ -26,8 +27,8 @@ class TestStateTransitions():
def test_StateTransitions(self, config, expected_files) -> None:

output_files = ["1_1_1_Positive_path_stats_vis.pdf", "1_1_1_Positive_path_stats.xlsx", "1_1_1_Positive.gv", "1_1_1_Positive.gv.pdf"]
path_to_enter_point = os.path.abspath(os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, ".."))
path_to_actual_output = os.path.abspath(os.path.join(path_to_enter_point, "code", "cov_tool", "output", "1_1_1_Positive"))
path_to_enter_point = os.path.abspath(os.path.join(GLOBAL.GLOBAL.path_from_test_to_util))
path_to_actual_output = os.path.abspath(os.path.join(path_to_enter_point, "..", "code", "output", "1_1_1_Positive"))
path_to_expected_output = os.path.join(GLOBAL.GLOBAL.path_from_test_to_expected, expected_files)
path_to_expected_std = os.path.join(GLOBAL.GLOBAL.path_from_test_to_expected, "..")

Expand Down Expand Up @@ -55,14 +56,14 @@ def test_StateTransitions(self, config, expected_files) -> None:
with allure.step("Validations"):
with allure.step("Artifacts"):
with allure.step("Exit Code"):
print(actual_artifacts["STDERR"].decode())
#print(codecs.decode(actual_artifacts["STDERR"], encoding='unicode_escape'))
assert 0 == actual_artifacts["ReturnCode"]
with allure.step("STDOUT"):
expected_stdout = '\n'+std_exp.read_file("std.yml")["stdout"]["positive_1_1_1"]+path_to_actual_output+'\n'
assert expected_stdout.replace('\r', '') == actual_artifacts["STDOUT"].decode().replace('\r', '')
#assert expected_stdout.replace('\r', '') == codecs.decode(actual_artifacts["STDOUT"], encoding='unicode_escape').replace('\r', '')
with allure.step("STDERR"):
mpl_err = "Matplotlib is building the font cache; this may take a moment."+'\n'
assert '' == actual_artifacts["STDERR"].decode() or mpl_err == actual_artifacts["STDERR"].decode().replace('\r', '')
#assert '' == codecs.decode(actual_artifacts["STDERR"], encoding='unicode_escape') or mpl_err == codecs.decode(actual_artifacts["STDERR"], encoding='unicode_escape').replace('\r', '')

with allure.step("Output Files"):
with allure.step(output_files[2]):
Expand Down Expand Up @@ -91,8 +92,8 @@ class TestTraceabilityMatrix():
def test_TraceabilityMatrix(self, config, expected_files) -> None:

output_files = ["1_2_1_Positive_param_trace.xlsx"]
path_to_enter_point = os.path.abspath(os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, ".."))
path_to_actual_output = os.path.abspath(os.path.join(path_to_enter_point, "code", "cov_tool", "output", "1_2_1_Positive"))
path_to_enter_point = os.path.abspath(os.path.join(GLOBAL.GLOBAL.path_from_test_to_util))
path_to_actual_output = os.path.abspath(os.path.join(path_to_enter_point, "..", "code", "output", "1_2_1_Positive"))
path_to_expected_output = os.path.join(GLOBAL.GLOBAL.path_from_test_to_expected, expected_files)
path_to_expected_std = os.path.join(GLOBAL.GLOBAL.path_from_test_to_expected, "..")

Expand All @@ -118,14 +119,14 @@ def test_TraceabilityMatrix(self, config, expected_files) -> None:
with allure.step("Validations"):
with allure.step("Artifacts"):
with allure.step("Exit Code"):
print(actual_artifacts["STDERR"].decode())
#print(codecs.decode(actual_artifacts["STDERR"], encoding='unicode_escape'))
assert 0 == actual_artifacts["ReturnCode"]
with allure.step("STDOUT"):
expected_stdout = '\n'+std_exp.read_file("std.yml")["stdout"]["positive_1_2_1"]+path_to_actual_output+'\n'
assert expected_stdout.replace('\r', '') == actual_artifacts["STDOUT"].decode().replace('\r', '')
#assert expected_stdout.replace('\r', '') == codecs.decode(actual_artifacts["STDOUT"], encoding='unicode_escape').replace('\r', '')
with allure.step("STDERR"):
mpl_err = "Matplotlib is building the font cache; this may take a moment."+'\n'
assert '' == actual_artifacts["STDERR"].decode() or mpl_err == actual_artifacts["STDERR"].decode().replace('\r', '')
#assert '' == actual_artifacts["STDERR"] or mpl_err == codecs.decode(actual_artifacts["STDERR"], encoding='unicode_escape').replace('\r', '')

with allure.step("Output Files"):
with allure.step(output_files[0]):
Expand Down
8 changes: 4 additions & 4 deletions code/test/test_2_2_Run_Arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def test_RunAgruments(self, case_id, run_arguments):
_output_files_list_empty_config = ["EX_TEST_path_stats_vis.pdf", "EX_TEST_path_stats.xlsx", "EX_TEST.gv", "EX_TEST.gv.pdf", "EX_TEST_param_trace.xlsx"]

#Path to output directory
_path_to_out_f = os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, "output", "2_2_2_Positive", "case_1")
_path_to_out_s = os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, "output", "2_2_2_Positive", "case_2")
_path_to_out_f = os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, "..", "output", "2_2_2_Positive", "case_1")
_path_to_out_s = os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, "..", "output", "2_2_2_Positive", "case_2")

with allure.step("Preconditions"):
with allure.step("Flush output"):
if case_id:
_out_files_empty = os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, "output", case_id)
_out_files_empty = os.path.join(GLOBAL.GLOBAL.path_from_test_to_util, "..", "output", case_id)
_output_files_e = files_processor.OutputManager(_out_files_empty)
_output_files_e.delete_files(files=_output_files_list_empty_config)
else:
Expand All @@ -47,7 +47,7 @@ def test_RunAgruments(self, case_id, run_arguments):

with allure.step("Run utility"):
_actual_artifacts = user.User().try_to_get_exit_artifacts(run_arguments)
print(_actual_artifacts["STDERR"].decode())
print(_actual_artifacts["STDERR"].decode('utf-8', errors='ignore'))

with allure.step("Postconditions"):
time.sleep(1)
Expand Down

0 comments on commit 074f2e4

Please sign in to comment.