Skip to content
This repository has been archived by the owner on Feb 21, 2025. It is now read-only.

Commit

Permalink
alskdj
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 committed Sep 4, 2023
1 parent d2e4ac9 commit d652157
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 10 additions & 2 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,15 @@ def fill(self, header: dict, document: dict) -> int:

return 0

def get(self, run_start, run_end, bad_only=False, with_ls_only=False):
def get(
self,
run_start: int,
run_end: int,
bad_only: bool = False,
with_ls_only: bool = False,
) -> list[tuple]:
"""
get data from 'runs' table with client's data
Get data from 'runs' table.
"""
self.log.debug("DQM2MirrorDB.get() - " + str(run_start) + " " + str(run_end))
with self.engine.connect() as cur:
Expand All @@ -369,6 +375,8 @@ def get(self, run_start, run_end, bad_only=False, with_ls_only=False):
+ f"WHERE run BETWEEN {run_start} AND {run_end} {postfix}"
).all()
self.log.debug(f"Read DB for runs {run_start}-{run_end}: {answer}")
print("!!!!!!!", answer)
answer[12] = TZ.localize(answer[11], is_dst=None)
return answer

def make_mirror_entry(self, data):
Expand Down
9 changes: 5 additions & 4 deletions tests/test_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def test_db_10(testing_database):
123456,
-1,
"id",
datetime(2012, 3, 3, 10, 10, 10).timestamp(),
datetime(2012, 3, 3, 10, 10, 10).timestamp(),
TZ.localize(datetime(2012, 3, 3, 10, 10, 10), is_dst=None).timestamp(),
TZ.localize(datetime(2012, 3, 3, 10, 10, 10), is_dst=None).timestamp(),
"",
"",
]
Expand All @@ -246,6 +246,7 @@ def test_db_10(testing_database):
testing_database.fill_graph(header, document)
answer = testing_database.get_graphs_data(123456)
print(answer)
print(truth)
assert all([c1 == c2 for c1, c2 in zip(truth, answer)])


Expand All @@ -265,13 +266,13 @@ def test_db_11(testing_database):
"",
"",
"",
datetime(2012, 3, 3, 10, 10, 10),
TZ.localize(datetime(2012, 3, 3, 10, 10, 10), is_dst=None),
"",
)
header = {"_id": "id", "run": "123456"}
document = {}
testing_database.fill(header, document)
answer = testing_database.get(123456, 123456)[0]
answer = testing_database.get(run_start=123456, run_end=123456)[0]
print(answer)
with testing_database.engine.connect() as cur:
session = testing_database.Session(bind=cur)
Expand Down

0 comments on commit d652157

Please sign in to comment.