Skip to content

Commit

Permalink
(tests.utils)(MegaTest) checking archivist credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Aug 27, 2024
1 parent f687724 commit 2acb1d9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import collections
import fnmatch
import os
import socket # gethostname
from types import ModuleType
from typing import Dict, List

Expand All @@ -10,9 +12,43 @@
# ^ {branch_script: ["Game"]}

test_maps_dir = os.path.join(os.getcwd(), "tests/maps")
# TODO: we can't safely assume cwd() is tests/../
# -- use __file__ to get the test maps dir instead

ArchiveDirs = collections.namedtuple("ArchiveDirs", ["steam_dir", "mod_dir"])

archivist_aliases = {"Jared@ITANI_WAYSOUND": "bikkie"}

archivists = {
# Windows Desktop
("bikkie", "ITANI_WAYSOUND"): ArchiveDirs(
"D:/SteamLibrary/steamapps/common/",
"E:/Mod/"),
# Linux Laptop
("bikkie", "coplandbentokom-9876"): ArchiveDirs(
None,
"/media/bikkie/3964-39352/Mod/")}


def archive_available() -> bool:
return archivist_login() in archivists


def archive_dirs() -> ArchiveDirs:
return archivists.get(archivist_login(), ArchiveDirs(*[None] * 2))


def archivist_login() -> (str, str):
user = os.getenv("USERNAME", os.getenv("USER"))
host = os.getenv("HOSTNAME", os.getenv("COMPUTERNAME", socket.gethostname()))
user = archivist_aliases.get(f"{user}@{host}", user)
return (user, host)


# TODO: include maplist.installed_games test_maps
# -- should use archivists[archivist_login()] to get dirs
# -- will require a refactor of maplist
# -- megatest spec lists would be really handy too
def get_test_maps(BspClass: Bsp, branch_dirs: BranchDirs, pattern: str = "*.bsp") -> Dict[str, Bsp]:
bsps = dict()
for branch in branch_dirs:
Expand Down

0 comments on commit 2acb1d9

Please sign in to comment.