Skip to content

Commit

Permalink
Merge pull request #341 from AstarVienna/fh/no-webtest
Browse files Browse the repository at this point in the history
Rearrange CI tests
  • Loading branch information
teutoburg authored Jan 17, 2024
2 parents 3d174ef + c4d45c4 commit 44f5926
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 48 deletions.
1 change: 1 addition & 0 deletions .github/workflows/notebooks_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:

jobs:
run_notebooks:
name: ${{ matrix.os }}, ${{ matrix.python-version }}
strategy:
matrix:
# Run all operating systems, because this is the first interaction
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/notebooks_with_irdb_clone.yml

This file was deleted.

18 changes: 17 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ on:

jobs:
call-tests:
name: Call tests
name: Offline tests
uses: AstarVienna/DevOps/.github/workflows/tests.yml@poetry
secrets: inherit

call-webtests:
name: Network tests
uses: AstarVienna/DevOps/.github/workflows/webtests.yml@poetry
secrets: inherit

call-updated-tests:
name: Tests with updated dependencies
uses: AstarVienna/DevOps/.github/workflows/updated_tests.yml@poetry
secrets: inherit

call-notebooks-with-clone:
name: Notebook tests
uses: ./.github/workflows/notebooks_dispatch.yml
with:
clone-irdb: true
27 changes: 5 additions & 22 deletions scopesim/tests/tests_server/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,68 +58,60 @@ def test_throws_for_nonexisting_release(self):
db._get_zipname("test_package", "bogus", self.all_pkg)


@pytest.mark.webtest
class TestGetServerFolderContents:
@pytest.mark.webtest
def test_downloads_locations(self, mock_client):
pkgs = list(db.get_server_folder_contents(mock_client, "locations"))
assert len(pkgs) > 0

@pytest.mark.webtest
def test_downloads_telescopes(self, mock_client):
pkgs = list(db.get_server_folder_contents(mock_client, "telescopes"))
assert len(pkgs) > 0

@pytest.mark.webtest
def test_downloads_instruments(self, mock_client):
pkgs = list(db.get_server_folder_contents(mock_client, "instruments"))
assert len(pkgs) > 0

@pytest.mark.webtest
def test_finds_armazones(self, mock_client):
pkgs = list(db.get_server_folder_contents(mock_client, "locations"))
assert "Armazones" in pkgs[0]

@pytest.mark.webtest
def test_throws_for_wrong_url_server(self):
with db.create_client("https://scopesim.univie.ac.at/bogus/") as client:
with pytest.raises(db.ServerError):
list(db.get_server_folder_contents(client, "locations"))


@pytest.mark.webtest
class TestGetServerElements:
@pytest.mark.webtest
def test_throws_an_error_if_url_doesnt_exist(self):
with pytest.raises(ValueError):
dbex.get_server_elements(url="www.bogus.server")

@pytest.mark.webtest
def test_returns_folders_if_server_exists(self):
url = rc.__config__["!SIM.file.server_base_url"]
pkgs = dbex.get_server_elements(url)
assert all([loc in pkgs for loc in
["locations/", "telescopes/", "instruments/"]])

@pytest.mark.webtest
def test_returns_files_if_zips_exist(self):
url = rc.__config__["!SIM.file.server_base_url"]
dir = "instruments/"
pkgs = dbex.get_server_elements(url + dir, ".zip")
assert "test_package.zip" in pkgs


@pytest.mark.webtest
class TestListPackages:
@pytest.mark.webtest
def test_lists_all_packages_without_qualifier(self):
pkgs = db.list_packages()
assert "Armazones" in pkgs
assert "MICADO" in pkgs

@pytest.mark.webtest
def test_lists_only_packages_with_qualifier(self):
pkgs = db.list_packages("Armazones")
assert np.all(["Armazones" in pkg for pkg in pkgs])

@pytest.mark.webtest
def test_throws_for_nonexisting_pkgname(self):
with pytest.raises(ValueError):
db.list_packages("bogus")
Expand All @@ -146,8 +138,8 @@ def test_downloads_package_successfully(self):
# db.download_package("instruments/bogus.zip")


@pytest.mark.webtest
class TestDownloadPackages:
@pytest.mark.webtest
def test_downloads_stable_package(self):
with TemporaryDirectory() as tmpdir:
db.download_packages(["test_package"], release="stable",
Expand All @@ -161,7 +153,6 @@ def test_downloads_stable_package(self):
version_dict = yaml.full_load(f)
assert version_dict["release"] == "stable"

@pytest.mark.webtest
def test_downloads_latest_package(self):
with TemporaryDirectory() as tmpdir:
db.download_packages("test_package", release="latest",
Expand All @@ -172,7 +163,6 @@ def test_downloads_latest_package(self):

assert version_dict["release"] == "dev"

@pytest.mark.webtest
def test_downloads_specific_package(self):
release = "2022-04-09.dev"
with TemporaryDirectory() as tmpdir:
Expand All @@ -184,8 +174,6 @@ def test_downloads_specific_package(self):

assert version_dict["version"] == release

# @pytest.mark.skip(reason="fails too often with timeout")
@pytest.mark.webtest
def test_downloads_github_version_of_package_with_semicolon(self):
release = "github:728761fc76adb548696205139e4e9a4260401dfc"
with TemporaryDirectory() as tmpdir:
Expand All @@ -195,8 +183,6 @@ def test_downloads_github_version_of_package_with_semicolon(self):

assert filename.exists()

# @pytest.mark.skip(reason="fails too often with timeout")
@pytest.mark.webtest
def test_downloads_github_version_of_package_with_at_symbol(self):
release = "github@728761fc76adb548696205139e4e9a4260401dfc"
with TemporaryDirectory() as tmpdir:
Expand All @@ -207,9 +193,8 @@ def test_downloads_github_version_of_package_with_at_symbol(self):
assert filename.exists()


# @pytest.mark.skip(reason="fails too often with timeout")
@pytest.mark.webtest
class TestDownloadGithubFolder:
@pytest.mark.webtest
def test_downloads_current_package(self):
with TemporaryDirectory() as tmpdir:
# tmpdir = "."
Expand All @@ -219,7 +204,6 @@ def test_downloads_current_package(self):

assert filename.exists()

@pytest.mark.webtest
def test_downloads_with_old_commit_hash(self):
with TemporaryDirectory() as tmpdir:
url = "https://github.com/AstarVienna/irdb/tree/728761fc76adb548696205139e4e9a4260401dfc/ELT"
Expand All @@ -228,7 +212,6 @@ def test_downloads_with_old_commit_hash(self):

assert filename.exists()

@pytest.mark.webtest
def test_throws_for_bad_url(self):
with TemporaryDirectory() as tmpdir:
url = "https://github.com/AstarVienna/irdb/tree/bogus/MICADO"
Expand Down

0 comments on commit 44f5926

Please sign in to comment.