Skip to content

Refactor tests. #92

Draft
RodneyCodess wants to merge 88 commits into
ubccr:v1.x.yfrom
RodneyCodess:refactor_tests
Draft

Refactor tests. #92
RodneyCodess wants to merge 88 commits into
ubccr:v1.x.yfrom
RodneyCodess:refactor_tests

Conversation

@RodneyCodess

@RodneyCodess RodneyCodess commented May 28, 2026

Copy link
Copy Markdown

Description

Motivation and Context

Tests performed

Type of change:

  • Refactoring / documentation update (non-breaking change which does not change functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix, feature, or removal that would cause existing functionality to change)
  • Release preparation

Checklist:

  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request
  • Updates have been made to the xdmod-notebooks repository as necessary, and the notebooks all run successfully

Comment thread .circleci/config.yml Outdated
name: Spin up containers and test different Python versions against different XDMoD web server versions
command: ./tests/ci/scripts/run-tests.sh
name: Build XDMoD web server images
command: bash ./tests/ci/scripts/build_xdmod_img.sh "<< parameters.xdmod_version >>"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of providing "<< parameters.xdmod_version >>" as an argument and setting XDMOD_VERSION="$1" in the script, I think it would be simpler to set it as an environment variable using environment; see here for an example.

Comment thread .circleci/config.yml Outdated
at: .
- run:
name: Run tests against XDMoD web server image
command: bash ./tests/ci/scripts/run_tests.sh "<< parameters.xdmod_version >>" "<< parameters.python_version >>"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note on using environment.

@aaronweeden aaronweeden added this to the 1.2.0 milestone Jun 11, 2026
@aaronweeden aaronweeden added the qa/testing Updates/additions to tests label Jun 11, 2026
Comment thread tests/ci/scripts/build_xdmod_img.sh Outdated
@@ -0,0 +1,56 @@
#!/bin/bash
set -eo pipefail

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -eo pipefail
set -exo pipefail

Comment thread tests/ci/scripts/build_xdmod_img.sh Outdated
@@ -0,0 +1,56 @@
#!/bin/bash
set -eo pipefail

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set -eo pipefail
set -exo pipefail

Comment thread .circleci/config.yml Outdated
at: .
- run:
name: Run tests against XDMoD web server image
command: bash ./tests/ci/scripts/run_tests.sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
command: bash ./tests/ci/scripts/run_tests.sh
command: ./tests/ci/scripts/run_tests.sh

Comment thread .circleci/config.yml Outdated
name: Spin up containers and test different Python versions against different XDMoD web server versions
command: ./tests/ci/scripts/run-tests.sh
name: Build XDMoD web server images
command: bash ./tests/ci/scripts/build_xdmod_img.sh "<< parameters.xdmod_version >>"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
command: bash ./tests/ci/scripts/build_xdmod_img.sh "<< parameters.xdmod_version >>"
command: ./tests/ci/scripts/build_xdmod_img.sh "<< parameters.xdmod_version >>"

Comment thread .circleci/config.yml Outdated
at: .
- run:
name: Generate coverage report
command: bash ./tests/ci/scripts/generate_coverage_report.sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
command: bash ./tests/ci/scripts/generate_coverage_report.sh
command: ./tests/ci/scripts/generate_coverage_report.sh

Comment thread .circleci/config.yml
Comment thread .circleci/config.yml Outdated
name: Spin up containers and test different Python versions against different XDMoD web server versions
command: ./tests/ci/scripts/run-tests.sh
name: Build XDMoD web server images
command: ./tests/ci/scripts/build_xdmod_img.sh "<< parameters.xdmod_version >>"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
command: ./tests/ci/scripts/build_xdmod_img.sh "<< parameters.xdmod_version >>"
command: ./tests/ci/scripts/build_xdmod_img.sh

If you set the environment variable XDMOD_VERSION above then you don't need to pass it in here.

Comment thread .circleci/config.yml
Comment on lines +13 to +15
parameters:
xdmod_version:
type: string

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parameters:
xdmod_version:
type: string
parameters:
xdmod_version:
type: string
environment:
XDMOD_VERSION: << parameters.xdmod_version >>

Add this environment variable that can be used later.

Comment thread .circleci/config.yml Outdated
Comment on lines +84 to +85


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Remove these two blank lines.

Comment thread tests/ci/scripts/build_xdmod_img.sh Outdated
@@ -0,0 +1,56 @@
#!/bin/bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#!/bin/bash
#!/bin/bash

Comment thread tests/ci/scripts/run_tests.sh Outdated
Comment on lines +38 to +45
rest_token=$(curl --cacert "$(pwd)/localhost.crt" -sS -X POST -c xdmod.cookie -d 'username=normaluser&password=normaluser' https://localhost:8080/rest/auth/login | jq -r '.results.token')
api_token=$(curl --cacert "$(pwd)/localhost.crt" -sS -X POST -b xdmod.cookie "https://localhost:8080/rest/users/current/api/token?token=$rest_token" | jq -r '.data.token')

# write the token where the tests read it
echo "XDMOD_API_TOKEN=$api_token" > ~/.xdmod-data-token

# trust the cert for requests
cat "$(pwd)/localhost.crt" >> "$(python3 -c 'import certifi; print(certifi.where())')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rest_token=$(curl --cacert "$(pwd)/localhost.crt" -sS -X POST -c xdmod.cookie -d 'username=normaluser&password=normaluser' https://localhost:8080/rest/auth/login | jq -r '.results.token')
api_token=$(curl --cacert "$(pwd)/localhost.crt" -sS -X POST -b xdmod.cookie "https://localhost:8080/rest/users/current/api/token?token=$rest_token" | jq -r '.data.token')
# write the token where the tests read it
echo "XDMOD_API_TOKEN=$api_token" > ~/.xdmod-data-token
# trust the cert for requests
cat "$(pwd)/localhost.crt" >> "$(python3 -c 'import certifi; print(certifi.where())')"
rest_token=$(curl --cacert "localhost.crt" -sS -X POST -c xdmod.cookie -d 'username=normaluser&password=normaluser' https://localhost:8080/rest/auth/login | jq -r '.results.token')
api_token=$(curl --cacert "localhost.crt" -sS -X POST -b xdmod.cookie "https://localhost:8080/rest/users/current/api/token?token=$rest_token" | jq -r '.data.token')
# write the token where the tests read it
echo "XDMOD_API_TOKEN=$api_token" > ~/.xdmod-data-token
# trust the cert for requests
cat "localhost.crt" >> "$(python3 -c 'import certifi; print(certifi.where())')"

The $(pwd) should be unnecessary.


REQUESTS_CA_BUNDLE=localhost.crt XDMOD_HOST="https://localhost:8080" python3 -m pytest --cov --cov-branch -vvs -o log_cli=true tests/

mv .coverage ".coverage.${PYTHON_VERSION}.${XDMOD_VERSION}" No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need newline at end of file.

data,
dtype='string',
index_col=0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Remove empty line.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stopped here

Comment on lines +75 to +97
@@ -94,7 +94,7 @@ def __get_data_dir(override_default_data=False):
],
},
},
'33346',
('33346', '33346'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'54749',
'raw-data-every-1000-no-fields-no-filters.csv',
),
(
@@ -94,31 +94,34 @@
],
},
},
'33346',

I would set it to just the new number and move the comment later; see below.

Comment on lines +122 to +124
xdmod_main_number, xdmod_11_number = number
expected_number = xdmod_main_number if XDMOD_VERSION in ['xdmod-11-0', 'xdmod-11-0-dev'] else xdmod_11_number
assert 'Got ' + expected_number + ' rows...DONE' in capsys.readouterr().out

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
xdmod_main_number, xdmod_11_number = number
expected_number = xdmod_main_number if XDMOD_VERSION in ['xdmod-11-0', 'xdmod-11-0-dev'] else xdmod_11_number
assert 'Got ' + expected_number + ' rows...DONE' in capsys.readouterr().out
# This PR added an extra job: https://github.com/ubccr/xdmod/pull/2176
if XDMOD_VERSION in ['xdmod-11-0', 'xdmod-11-0-dev']:
number -= 1
assert 'Got ' + number + ' rows...DONE' in capsys.readouterr().out

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this and 1 above

Comment thread tests/ci/scripts/run_tests.sh Outdated
Comment on lines +23 to +24
python3 -m pip install --upgrade flake8 flake8-commas flake8-quotes
python3 -m flake8 . --max-complexity=10 --max-line-length=160 --show-source --exclude __init__.py

@aaronweeden aaronweeden Jun 18, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we move linting into a separate workflow in .circleci/config.yml so that if linting fails it doesn't fail the entire workflow — this can be annoying when developing a PR.

We could have the current workflow workflow be renamed to build_and_test and the new one be called lint.

RodneyCodess and others added 5 commits June 18, 2026 12:00
Co-authored-by: Aaron Weeden <31246768+aaronweeden@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qa/testing Updates/additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants