Skip to content

Commit

Permalink
add report example.
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanelsayeed committed Jul 25, 2024
1 parent 7551de9 commit 0b4010c
Show file tree
Hide file tree
Showing 336 changed files with 1,594 additions and 67 deletions.
106 changes: 106 additions & 0 deletions app/file_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
"""
This module contains the FileState class.
"""


from __future__ import annotations
import datetime


class FileState:
"""
File state class
"""

def __init__(self, status: str = "init"):

self.status: str = status

self.date_format: str = "%Y-%m-%d %H:%M:%S"

self.__init_time: datetime = datetime.datetime.now().strftime(self.date_format)

self._last_update: str | datetime = self.__init_time
self._start_time: str | datetime = self.__init_time
self._end_time: str | datetime = self.__init_time

def datetime_to_str(self, datetime_str: str) -> str:
return datetime.datetime.strptime(datetime_str, self.date_format).strftime(self.date_format)

@property
def last_update(self) -> str:
return self._last_update

@last_update.setter
def last_update(self, value: str | datetime) -> None:
self._last_update = self.datetime_to_str(value)

@property
def start_time(self) -> str:
return self._start_time

@start_time.setter
def start_time(self, value: str | datetime) -> None:
self._start_time = self.datetime_to_str(value)

@property
def end_time(self) -> str:
return self._end_time

@end_time.setter
def end_time(self, value: str | datetime) -> None:
self._end_time = self.datetime_to_str(value)

def __update_last_update(self) -> None:
"""
Update last update time
:return: None
"""
self.last_update = datetime.datetime.now().strftime(self.date_format)

def __getitem__(self, item):
return getattr(self, item)

def __setitem__(self, key, value):
# update last update time
self.__update_last_update()
return setattr(self, key, value)

def update(self, other: FileState | dict):
"""
Update file state
:param other:
:return:
"""

for key, value in vars(other).items():
if key.startswith("_"):
continue
# update last update time
self.__update_last_update()
setattr(self, key, value)

def __str__(self):
return f"FileState({vars(self)})"

def to_dict(self):
# return only properties
return {key: getattr(self, key) for key in dir(self) if not key.startswith("_") and not callable(getattr(self, key))}


if __name__ == "__main__":
file_state = FileState()
# another_file_state = FileState(status="another_status")
# print(file_state)
# print(file_state["status"])
# file_state.update(another_file_state)
# print(file_state["status"])
print("1", type(file_state.start_time))
file_state.start_time = datetime.datetime.now().strftime(file_state.date_format)
print("2", type(file_state.start_time))

print(file_state.to_dict())
2 changes: 2 additions & 0 deletions docs/app.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/data/attachments/13ca91c229df477e.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_2
1 change: 1 addition & 0 deletions docs/data/attachments/1a5712fc03533fc8.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_2
1 change: 1 addition & 0 deletions docs/data/attachments/1ce7c9397fde6fe3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_3
1 change: 1 addition & 0 deletions docs/data/attachments/2b850292dce37c39.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_2
1 change: 1 addition & 0 deletions docs/data/attachments/2de6be49da046305.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_3
3 changes: 3 additions & 0 deletions docs/data/attachments/323f25e22a14fc48.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file name,size
file one,3
file two,4
1 change: 1 addition & 0 deletions docs/data/attachments/36287383d8a1e873.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_1
1 change: 1 addition & 0 deletions docs/data/attachments/46415d9b7aa67f0c.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_2
1 change: 1 addition & 0 deletions docs/data/attachments/51892ea0005f7f4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Attach text
18 changes: 18 additions & 0 deletions docs/data/attachments/5add6f78ae68f5f4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th>file name</th>
<th>time</th>
</tr>
</thead>
<tbody>
<tr>
<td>file one</td>
<td>3</td>
</tr>
<tr>
<td>file two</td>
<td>4</td>
</tr>
</tbody>
</table>
1 change: 1 addition & 0 deletions docs/data/attachments/5caecd4dec56581e.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Attach text
1 change: 1 addition & 0 deletions docs/data/attachments/6d1bb9d3fa8e15bd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ayman text of file go here
1 change: 1 addition & 0 deletions docs/data/attachments/784c08d9be6022f1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_1
1 change: 1 addition & 0 deletions docs/data/attachments/84e712b95fd172c6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_3
1 change: 1 addition & 0 deletions docs/data/attachments/a1209aa182e64314.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_3
1 change: 1 addition & 0 deletions docs/data/attachments/ab8750b67a2ac6a1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_failed_3
1 change: 1 addition & 0 deletions docs/data/attachments/b39eb4bd6724f341.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_failed_3
1 change: 1 addition & 0 deletions docs/data/attachments/b5a074fa5e1c89f0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_2
1 change: 1 addition & 0 deletions docs/data/attachments/b5bee4a620e7c155.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Attach html</h1>
1 change: 1 addition & 0 deletions docs/data/attachments/be5a9c745957fb71.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_3
1 change: 1 addition & 0 deletions docs/data/attachments/c2e307a3debe181e.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ayman Class teardown method
1 change: 1 addition & 0 deletions docs/data/attachments/c4b47e5a8b698bcd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_1
1 change: 1 addition & 0 deletions docs/data/attachments/c4d3b507b621f892.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_1
1 change: 1 addition & 0 deletions docs/data/attachments/c6d6acfd07f3ec23.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Attach html</h1>
1 change: 1 addition & 0 deletions docs/data/attachments/c8d8f33e0f2f878a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_3
1 change: 1 addition & 0 deletions docs/data/attachments/d08a2559eea206fb.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_teardown_1
1 change: 1 addition & 0 deletions docs/data/attachments/d49917f64ac28866.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ayman Class setup method
1 change: 1 addition & 0 deletions docs/data/attachments/e0a1d87e4f6d2446.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_1
18 changes: 18 additions & 0 deletions docs/data/attachments/e2c1e6d26d191a26.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th>file name</th>
<th>time</th>
</tr>
</thead>
<tbody>
<tr>
<td>file one</td>
<td>3</td>
</tr>
<tr>
<td>file two</td>
<td>4</td>
</tr>
</tbody>
</table>
1 change: 1 addition & 0 deletions docs/data/attachments/e3cc672dd8493aaf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_2
1 change: 1 addition & 0 deletions docs/data/attachments/eb7ab7336d8efb2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_failed_2
1 change: 1 addition & 0 deletions docs/data/attachments/ec37d1bf2966cdf4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
teardown method test_running_time
1 change: 1 addition & 0 deletions docs/data/attachments/ed39593e7465c233.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_failed_1
1 change: 1 addition & 0 deletions docs/data/attachments/f76bd1ec7e2b5254.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setup method test_setup_failed_1
3 changes: 3 additions & 0 deletions docs/data/attachments/faf395397008fc4f.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
file name,size
file one,3
file two,4
3 changes: 3 additions & 0 deletions docs/data/behaviors.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"Epic","Feature","Story","FAILED","BROKEN","PASSED","SKIPPED","UNKNOWN"
"","","","4","99","36","107","0"
"","","Reports","0","0","4","0","0"
1 change: 1 addition & 0 deletions docs/data/behaviors.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/data/categories.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"Category","FAILED","BROKEN","PASSED","SKIPPED","UNKNOWN"
"Product defects","4","0","0","0","0"
"Test defects","0","99","0","0","0"
1 change: 1 addition & 0 deletions docs/data/categories.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/data/packages.json

Large diffs are not rendered by default.

Loading

0 comments on commit 0b4010c

Please sign in to comment.