mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
adding the unit testing and modify some function for my unit testing its pretty good i learn how to get a good struct for my classes
This commit is contained in:
+64
-9
@@ -1,14 +1,69 @@
|
||||
from parsing.Parsing import DataMaze
|
||||
import pytest
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Unit Testing for parsing:")
|
||||
data = DataMaze.get_data("config.txt")
|
||||
data_t = DataMaze.transform_data(data)
|
||||
data_t = DataMaze.verif_key_data(data_t)
|
||||
data_t = DataMaze.verif_value_data(data_t)
|
||||
print(data_t)
|
||||
class TestParsing:
|
||||
|
||||
def test_get_data_valid(self):
|
||||
data = DataMaze.get_file_data("tests/test_txt/config_1.txt")
|
||||
assert isinstance(data, str) is True
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
def test_file_error(self):
|
||||
with pytest.raises(FileNotFoundError):
|
||||
DataMaze.get_file_data("tete")
|
||||
|
||||
def test_permission_error(self):
|
||||
with pytest.raises(PermissionError):
|
||||
DataMaze.get_file_data("tests/test_txt/error_1.txt")
|
||||
|
||||
def test_empty_file_error(self):
|
||||
with pytest.raises(ValueError):
|
||||
DataMaze.get_file_data("tests/test_txt/error_6.txt")
|
||||
|
||||
def test_transform_data_valid(self):
|
||||
data = DataMaze.get_file_data("tests/test_txt/config_1.txt")
|
||||
data_2 = DataMaze.transform_data(data)
|
||||
assert isinstance(data_2, dict)
|
||||
|
||||
def test_transform__index_error(self):
|
||||
with pytest.raises(IndexError):
|
||||
DataMaze.transform_data("asdasdasdasdasdasda\nasdasdas=asdasd")
|
||||
|
||||
def test_key_data_error(self):
|
||||
with pytest.raises(KeyError):
|
||||
data = DataMaze.get_file_data("tests/test_txt/error_8.txt")
|
||||
data2 = DataMaze.transform_data(data)
|
||||
DataMaze.verif_key_data(data2)
|
||||
|
||||
def test_key_data_error_2(self):
|
||||
with pytest.raises(KeyError):
|
||||
data = DataMaze.get_file_data("tests/test_txt/error_9.txt")
|
||||
data2 = DataMaze.transform_data(data)
|
||||
DataMaze.verif_key_data(data2)
|
||||
|
||||
def test_convert_int(self):
|
||||
with pytest.raises(ValueError):
|
||||
data = DataMaze.get_file_data("tests/test_txt/error_2.txt")
|
||||
data2 = DataMaze.transform_data(data)
|
||||
DataMaze.convert_values(data2)
|
||||
|
||||
def test_tuple_error(self):
|
||||
with pytest.raises(ValueError):
|
||||
DataMaze.convert_tuple("0,3,5,5")
|
||||
|
||||
def test_tuple_error1(self):
|
||||
with pytest.raises(AttributeError):
|
||||
DataMaze.convert_tuple(None)
|
||||
|
||||
def test_bool_error(self):
|
||||
with pytest.raises(ValueError):
|
||||
DataMaze.convert_bool("Trueeee")
|
||||
|
||||
def test_valid_tuple(self):
|
||||
assert DataMaze.convert_tuple("7534564654, 78") == (7534564654, 78)
|
||||
|
||||
def test_valid_bool(self):
|
||||
assert DataMaze.convert_bool("False") is False
|
||||
|
||||
def test_valid_bool1(self):
|
||||
assert DataMaze.convert_bool("True") is True
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
WIDTH=200
|
||||
HEIGHT=100
|
||||
ENTRY=0,0
|
||||
EXIT=19,14
|
||||
OUTPUT_FILE=maze.txt
|
||||
PERFECT=True
|
||||
@@ -0,0 +1,6 @@
|
||||
WIDTH=200
|
||||
HEIGHT=100
|
||||
ENTRY=0,0
|
||||
EXIT=19,14
|
||||
OUTPUT_FILE=maze.txt
|
||||
PERFECT=True
|
||||
@@ -0,0 +1,6 @@
|
||||
WIDTH=caca
|
||||
HEIGHT=100
|
||||
ENTRY=0,0
|
||||
EXIT=19,14
|
||||
OUTPUT_FILE=maze.txt
|
||||
PERFECT=True
|
||||
@@ -0,0 +1,4 @@
|
||||
WIDTH=200
|
||||
HEIGHT=100
|
||||
ENTRY=0,0
|
||||
EXIT=19,14
|
||||
@@ -0,0 +1,7 @@
|
||||
WIDTH=200
|
||||
HEIGHT=100
|
||||
ENTRY=0,0
|
||||
EXIT=19,14
|
||||
OUTPUT_FILE=maze.txt
|
||||
PERFECT=True
|
||||
PIPI=tut
|
||||
Reference in New Issue
Block a user