Skip to content

Commit

Permalink
Actually read librarian server name intests
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Mar 1, 2024
1 parent 4109d61 commit b7d78c9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_server(tmp_path_factory):
setup = server_setup(tmp_path_factory, name="test_server")

env_vars = {
"LIBRARIAN_SERVER_NAME": None,
"LIBRARIAN_CONFIG_PATH": None,
"LIBRARIAN_SERVER_DATABASE_DRIVER": None,
"LIBRARIAN_SERVER_DATABASE": None,
Expand Down
8 changes: 4 additions & 4 deletions tests/integration_test/test_sneaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_sneakernet_workflow(
# Before starting, register the downstream and upstream librarians.
with test_server_with_many_files_and_errors[1]() as session:
live_server = test_orm.Librarian.new_librarian(
name="librarian_server",
name="live_server",
url="http://localhost",
port=server.id,
check_connection=False,
Expand All @@ -45,7 +45,7 @@ def test_sneakernet_workflow(
with librarian_database_session_maker() as session:
# Note we will never actually access this.
test_server = test_orm.Librarian.new_librarian(
name="librarian_server",
name="test_server",
url="http://localhost",
port=test_server_with_many_files_and_errors[2].id,
check_connection=False,
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_sneakernet_workflow(
manifest = admin_client.get_store_manifest(
"local_sneaker",
create_outgoing_transfers=True,
destination_librarian="librarian_server",
destination_librarian="test_server",
disable_store=True,
mark_local_instances_as_unavailable=True,
)
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_sneakernet_workflow(

# Remote instance
assert len(instance.file.remote_instances) > 0
assert "librarian_server" in [
assert "test_server" in [
x.librarian.name for x in instance.file.remote_instances
]

Expand Down
5 changes: 5 additions & 0 deletions tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Server(BaseModel):
staging_directory: Path
store_directory: Path
database: Path
LIBRARIAN_SERVER_NAME: str
LIBRARIAN_SERVER_DISPLAYED_SITE_NAME: str
LIBRARIAN_CONFIG_PATH: str
LIBRARIAN_SERVER_DATABASE_DRIVER: str
LIBRARIAN_SERVER_DATABASE: str
Expand All @@ -34,6 +36,8 @@ class Server(BaseModel):
@property
def env(self) -> dict[str, str]:
return {
"LIBRARIAN_SERVER_NAME": self.LIBRARIAN_SERVER_NAME,
"LIBRARIAN_SERVER_DISPLAYED_SITE_NAME": self.LIBRARIAN_SERVER_DISPLAYED_SITE_NAME,
"LIBRARIAN_CONFIG_PATH": self.LIBRARIAN_CONFIG_PATH,
"LIBRARIAN_SERVER_DATABASE_DRIVER": self.LIBRARIAN_SERVER_DATABASE_DRIVER,
"LIBRARIAN_SERVER_DATABASE": self.LIBRARIAN_SERVER_DATABASE,
Expand Down Expand Up @@ -194,6 +198,7 @@ def server_setup(tmp_path_factory, name="librarian_server") -> Server:
store_directory=store_directory,
database=database,
LIBRARIAN_SERVER_NAME=name,
LIBRARIAN_SERVER_DISPLAYED_SITE_NAME=name.replace("_", " ").title(),
LIBRARIAN_CONFIG_PATH=librarian_config_path,
LIBRARIAN_SERVER_DATABASE_DRIVER="sqlite",
LIBRARIAN_SERVER_DATABASE=str(database),
Expand Down
2 changes: 1 addition & 1 deletion tests/server_unit_test/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_manifest_generation_and_extra_opts(
new_response = AdminStoreManifestResponse.model_validate_json(new_response.content)

assert new_response.store_name == response[0].name
assert new_response.librarian_name == "librarian_server"
assert new_response.librarian_name == "test_server"

session = get_session()

Expand Down

0 comments on commit b7d78c9

Please sign in to comment.