Skip to content

Commit

Permalink
Clean up unused remnants of old features
Browse files Browse the repository at this point in the history
  • Loading branch information
Jekannadar committed Nov 9, 2023
1 parent 71928b2 commit a476ad9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@

def init_database() -> None:
global database, parts, taxonomies, results
if "__compiled__" in globals():
if "__compiled__" in globals(): # pragma: no cover
application_path = os.path.dirname(sys.argv[0])
elif __file__:
application_path = os.path.dirname(__file__)
config_path = os.path.join(application_path, "config.ini")
container_path = os.path.join(application_path, "container")
config = configparser.ConfigParser()
if not os.path.exists(config_path) and not os.path.exists(container_path):
if not os.path.exists(config_path) and not os.path.exists(
container_path
): # pragma: no cover
is_remote = askyesno(
"Connect to remote DB?",
"Do you want to connect to a hosted MongoDB instance?",
)
connection_url: str | None = ""
if is_remote:
if is_remote: # pragma: no cover
connection_url = askstring(
"Remote URL",
"Please enter the connection url (with user and password, stored locally in plain text): ",
Expand All @@ -44,7 +46,7 @@ def init_database() -> None:
except errors.ServerSelectionTimeoutError as err:
showerror("Connection Error", "Could not connect to database. Exiting.")
exit(0)
else:
else: # pragma: no cover
database = MontyClient(os.path.join(application_path, "db"))
if askyesno("Import", "Import an existing database?"):
import_data = askopenfilename()
Expand Down Expand Up @@ -72,7 +74,7 @@ def init_database() -> None:
map_size="1073741824",
)
database = MontyClient(os.path.join(application_path, "db"))
else:
else: # pragma: no cover
config.read(config_path)
if config["db"]["is_remote"] and config["db"]["connection_url"] != "":
try:
Expand Down
15 changes: 4 additions & 11 deletions applications/cls-cad-backend/cls_cad_backend/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from starlette.responses import Response

base_json = True
try:
try: # pragma: no cover
import orjson
import ujson

base_json = False
except ImportError:
except ImportError: # pragma: no cover
pass


Expand All @@ -19,19 +19,12 @@ class FastResponse(Response):
def render(self, content: typing.Any) -> bytes:
if base_json:
return json.dumps(content, indent=2, ensure_ascii=False).encode("utf-8")
try:
try: # pragma: no cover
return orjson.dumps(content, option=orjson.OPT_INDENT_2)
except TypeError:
except TypeError: # pragma: no cover
try:
return ujson.dumps(content, indent=2, ensure_ascii=False).encode(
"utf-8"
)
except OverflowError:
return json.dumps(content, indent=2, ensure_ascii=False).encode("utf-8")


class BytesResponse(Response):
media_type = "application/json"

def render(self, content: typing.Any) -> bytes:
return content
5 changes: 0 additions & 5 deletions applications/cls-cad-backend/tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,3 @@ def test_upsert_parts():
}
response = client.post("/submit/part", json=test_payload)
assert response.status_code == 200


if __name__ == "__main__":
test_upsert_taxonomy()
test_upsert_parts()
7 changes: 0 additions & 7 deletions applications/cls-cad-backend/tests/test_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,3 @@ def test_synthesis_intersection_counting():
assert response.status_code == 200
assert response.text != "FAIL"
assert response.json()["count"] == 1


if __name__ == "__main__":
test_synthesis_simple()
test_synthesis_intersection()
test_synthesis_simple_counting()
test_synthesis_intersection_counting()

0 comments on commit a476ad9

Please sign in to comment.