Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/run-e2-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Python tests

on:
workflow_dispatch:
inputs:
server:
required: true
site:
required: true
patname:
required: true
pat:
required: true

jobs:
build:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python --version
python -m pip install --upgrade pip
pip install -e .[build]
pip install -e .[test]
doit version
python setup.py build

- name: Run e2e tests
run: |
python -m tabcmd login --server "${{ github.event.inputs.server }}" --site "${{ github.event.inputs.site }}" --token-name "${{ github.event.inputs.patname }}" --token-value "${{ github.event.inputs.pat }}"
pytest -q tests\e2e\online_tests.py -r pfE
59 changes: 44 additions & 15 deletions tests/e2e/online_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
# you can either run setup with a stored credentials file, or simply log in
# before running the suite so a session is active

# alpodev
parent_location = "WAM"
project_name = "Developer Platform"

server_admin = False
site_admin = True
project_admin = True


def _test_command(test_args: list[str]):
# this will raise an exception if it gets a non-zero return code
Expand All @@ -43,18 +51,18 @@ def setup_class(cls):
def _create_project(self, project_name, parent_path=None):
command = "createproject"
arguments = [command, "--name", project_name]
if parent_path:
if parent_path or parent_location:
arguments.append("--parent-project-path")
arguments.append(parent_path)
arguments.append(parent_path or parent_location)
print(arguments)
_test_command(arguments)

def _delete_project(self, project_name, parent_path=None):
command = "deleteproject"
arguments = [command, project_name]
if parent_path:
if parent_path or parent_location:
arguments.append("--parent-project-path")
arguments.append(parent_path)
arguments.append(parent_path or parent_location)
_test_command(arguments)

def _publish_samples(self, project_name):
Expand Down Expand Up @@ -135,20 +143,27 @@ def test_help(self):

@pytest.mark.order(2)
def test_create_site_users(self):
if not server_admin and not site_admin:
pytest.skip("Must be server or site administrator to create site users")
command = "createsiteusers"
users = os.path.join("tests", "assets", "detailed_users.csv")
arguments = [command, users, "--role", "Publisher"]
_test_command(arguments)

@pytest.mark.order(3)
def test_creategroup(self):
if not server_admin and not site_admin:
pytest.skip("Must be server or site administrator to create groups")
groupname = group_name
command = "creategroup"
arguments = [command, groupname]
_test_command(arguments)

@pytest.mark.order(4)
def test_add_users_to_group(self):
if not server_admin and not site_admin:
pytest.skip("Must be server or site administrator to add to groups")

groupname = group_name
command = "addusers"
filename = os.path.join("tests", "assets", "usernames.csv")
Expand All @@ -157,6 +172,9 @@ def test_add_users_to_group(self):

@pytest.mark.order(5)
def test_remove_users_to_group(self):
if not server_admin and not site_admin:
pytest.skip("Must be server or site administrator to remove from groups")

groupname = group_name
command = "removeusers"
filename = os.path.join("tests", "assets", "usernames.csv")
Expand All @@ -165,22 +183,19 @@ def test_remove_users_to_group(self):

@pytest.mark.order(6)
def test_deletegroup(self):
if not server_admin and not site_admin:
pytest.skip("Must be server or site administrator to delete groups")

groupname = group_name
command = "deletegroup"
arguments = [command, groupname]
_test_command(arguments)

@pytest.mark.order(7)
def test_publish_samples(self):
project_name = "sample-proj"
self._create_project(project_name)
time.sleep(indexing_sleep_time)

self._publish_samples(project_name)
self._delete_project(project_name)

@pytest.mark.order(8)
def test_create_projects(self):

if not project_admin:
pytest.skip("Must be project administrator to create projects")
# project 1
self._create_project(project_name)
time.sleep(indexing_sleep_time)
Expand All @@ -194,12 +209,14 @@ def test_create_projects(self):

@pytest.mark.order(9)
def test_delete_projects(self):
if not project_admin:
pytest.skip("Must be project administrator to create projects")
self._delete_project("project_name_2", project_name) # project 2
self._delete_project(project_name)

@pytest.mark.order(9)
def test_publish_samples(self):
self._publish_samples("Default")
self._publish_samples(project_name)

@pytest.mark.order(10)
def test_publish(self):
Expand Down Expand Up @@ -256,6 +273,7 @@ def test_create_extract(self):

@pytest.mark.order(14)
def test_refresh_extract(self):
# must be a datasource owned by the test user
name_on_server = OnlineCommandTest.TWBX_WITH_EXTRACT_NAME
self._refresh_extract(name_on_server)
self._delete_wb(name_on_server)
Expand Down Expand Up @@ -292,11 +310,22 @@ def test_export_view(self):

@pytest.mark.order(16)
def test_delete_site_users(self):
if not server_admin and not site_admin:
pytest.skip("Must be server or site administrator to delete site users")

command = "deletesiteusers"
users = os.path.join("tests", "assets", "usernames.csv")
_test_command([command, users])

@pytest.mark.order(20)
def test_list_sites(self):
if not server_admin:
pytest.skip("Must be server administrator to list sites")

command = "listsites"
_test_command([command])
try:
_test_command([command])
except Exception as E:
print("yay")
result = True
assert result