Skip to content

Commit

Permalink
Fix Import/Export server test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
khushboovashi authored and akshay-joshi committed Dec 19, 2023
1 parent 9828d86 commit d93c6e2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ if [ ! -f /var/lib/pgadmin/pgadmin4.db ]; then
# When running in Desktop mode, no user is created
# so we have to import servers anonymously
if [ "${PGADMIN_CONFIG_SERVER_MODE}" = "False" ]; then
/venv/bin/python3 /pgadmin4/setup.py --load-servers "${PGADMIN_SERVER_JSON_FILE}"
/venv/bin/python3 /pgadmin4/setup.py load-servers "${PGADMIN_SERVER_JSON_FILE}"
else
/venv/bin/python3 /pgadmin4/setup.py --load-servers "${PGADMIN_SERVER_JSON_FILE}" --user "${PGADMIN_DEFAULT_EMAIL}"
/venv/bin/python3 /pgadmin4/setup.py load-servers "${PGADMIN_SERVER_JSON_FILE}" --user "${PGADMIN_DEFAULT_EMAIL}"
fi
fi
fi
Expand Down
2 changes: 1 addition & 1 deletion web/pgadmin/browser/server_groups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def delete(self, gid):
# This matches the behavior of
# web/pgadmin/utils/__init.py__#clear_database_servers
# called by the setup script when importing and replacing servers:
# `python setup.py --load-servers input_file.json --replace`
# `python setup.py load-servers input_file.json --replace`
sg = groups.first()

shared_servers = Server.query.filter_by(servergroup_id=gid,
Expand Down
4 changes: 2 additions & 2 deletions web/pgadmin/setup/tests/test_export_import_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def runTest(self):

# Load the servers
os.system(
"python \"%s\" --load-servers \"%s\" 2> %s" %
"python \"%s\" load-servers \"%s\" 2> %s" %
(setup, os.path.join(path, "servers.json"), os.devnull)
)

# And dump them again
tf = tempfile.NamedTemporaryFile(delete=False)
os.system("python \"%s\" --dump-servers \"%s\" 2> %s" %
os.system("python \"%s\" dump-servers \"%s\" 2> %s" %
(setup, tf.name, os.devnull))

# Compare the JSON files, ignoring servers that exist in our
Expand Down
4 changes: 3 additions & 1 deletion web/pgadmin/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ def dump_database_servers(output_file, selected_servers,
servers = Server.query.filter_by(user_id=user_id).all()
server_dict = {}
for server in servers:
if selected_servers is None or str(server.id) in selected_servers:
if selected_servers is None or (type(selected_servers) == list
and len(selected_servers) == 0
) or str(server.id) in selected_servers:
# Get the group name
group_name = ServerGroup.query.filter_by(
user_id=user_id, id=server.servergroup_id).first().name
Expand Down

0 comments on commit d93c6e2

Please sign in to comment.