discotoolkit 1.2.1__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/PKG-INFO +9 -9
  2. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/README.md +8 -8
  3. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/GlobalVariable.py +16 -8
  4. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/__init__.py +1 -1
  5. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit.egg-info/PKG-INFO +9 -9
  6. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit.egg-info/SOURCES.txt +1 -0
  7. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/setup.py +1 -1
  8. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/tests/test_docs.py +22 -0
  9. discotoolkit-1.3.0/tests/test_metadata_helpers.py +49 -0
  10. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/tests/test_server_contract.py +1 -1
  11. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/tests/test_settings.py +26 -6
  12. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/MANIFEST.in +0 -0
  13. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/CELLiD.py +0 -0
  14. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/CellMapper.py +0 -0
  15. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/DiscoClass.py +0 -0
  16. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/DownloadDiscoData.py +0 -0
  17. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/GeneSearch.py +0 -0
  18. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/GetMetadata.py +0 -0
  19. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit/Utilities.py +0 -0
  20. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit.egg-info/dependency_links.txt +0 -0
  21. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit.egg-info/requires.txt +0 -0
  22. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/discotoolkit.egg-info/top_level.txt +0 -0
  23. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/pyproject.toml +0 -0
  24. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/requirements.txt +0 -0
  25. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/setup.cfg +0 -0
  26. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/tests/test_gene_search.py +0 -0
  27. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/tests/test_reference_loading.py +0 -0
  28. {discotoolkit-1.2.1 → discotoolkit-1.3.0}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: discotoolkit
3
- Version: 1.2.1
3
+ Version: 1.3.0
4
4
  Summary: DISCOtoolkit is an python package that allows users to access data and use the tools provided by the DISCO database.
5
5
  Home-page: https://disco.bii.a-star.edu.sg/
6
6
  Author: Li Mengwei, Rom Uddamvathanak
@@ -43,7 +43,7 @@ Dynamic: summary
43
43
  -->
44
44
  [![Documentation](https://img.shields.io/badge/docs-disco.bii.a--star.edu.sg-blue)](https://disco.bii.a-star.edu.sg/v1/docs/toolkit/guide/) [![Downloads](https://static.pepy.tech/personalized-badge/discotoolkit?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads)](https://pepy.tech/project/discotoolkit) [![PyPI version](https://img.shields.io/pypi/v/discotoolkit)](https://pypi.org/project/discotoolkit)
45
45
 
46
- # DISCOtoolkit 1.2.1
46
+ # DISCOtoolkit 1.3.0
47
47
 
48
48
  DISCOtoolkit is a Python package for accessing the data and tools of the [DISCO database](https://disco.bii.a-star.edu.sg/) (DISCO v1). Read the documentation, with tutorials and the API reference, at [disco.bii.a-star.edu.sg/v1/docs/toolkit/guide](https://disco.bii.a-star.edu.sg/v1/docs/toolkit/guide/).
49
49
 
@@ -52,7 +52,7 @@ DISCOtoolkit is a Python package for accessing the data and tools of the [DISCO
52
52
  - CELLiD: cell type annotation
53
53
  - scEnrichment: gene set enrichment using DISCO DEGs
54
54
 
55
- > **DISCO v1 and v2.** The toolkit talks to **DISCO v1** by default. DISCO v2 has its own R package ([DISCOtoolkit](https://github.com/JinmiaoChenLab/DISCOtoolkit)); the Python package can still be pointed at a v2 server, see [Choosing a server](#choosing-a-server).
55
+ > **For DISCO v1.** The toolkit is built for and tested against **DISCO v1**, which it uses by default. DISCO v2 is not supported; it has its own R package, [DISCOtoolkit](https://github.com/JinmiaoChenLab/DISCOtoolkit).
56
56
 
57
57
  ## Quickstart (Google Colab)
58
58
 
@@ -96,17 +96,17 @@ python -m ipykernel install --user --name disco --display-name "disco"
96
96
  python -m pip install -U discotoolkit
97
97
  ```
98
98
 
99
- ## Choosing a server
99
+ ## Server
100
100
 
101
101
  ```python
102
102
  import discotoolkit as dt
103
103
 
104
- dt.get_server() # 'https://disco.bii.a-star.edu.sg/disco_v3_api/' (DISCO v1, the default)
105
- dt.set_server("v2") # DISCO v2
106
- dt.set_server("https://my.server/disco_v3_api/") # any server with the same API
104
+ dt.get_server() # 'https://disco.bii.a-star.edu.sg/disco_v3_api/' (DISCO v1)
105
+ dt.set_server("https://my.mirror/disco_v3_api/") # a mirror or test copy of DISCO v1
107
106
  ```
108
107
 
109
- or set the `DISCO_API_URL` environment variable before importing the package.
108
+ or set the `DISCO_API_URL` environment variable before importing the package. The tests use this
109
+ to run against a local copy of DISCO v1.
110
110
 
111
111
  ## Testing
112
112
 
@@ -117,7 +117,7 @@ python tests/test_settings.py # offline: server selection logic
117
117
  python tests/test_version.py # offline: setup.py and __init__.py agree on the version
118
118
  python tests/test_docs.py # offline: notebooks are clean, every public function is in the API reference
119
119
  python tests/test_server_contract.py # online: does the server answer everything the toolkit needs?
120
- python tests/test_server_contract.py https://immunesinglecell.org/disco_v3_api/ # check another server
120
+ python tests/test_server_contract.py <api root> # check another server
121
121
  ```
122
122
 
123
123
  GitHub Actions runs these, and installs the package on Python 3.9-3.12, on every push. Maintainers: see [RELEASING.md](RELEASING.md) for how a release, and its documentation, is published.
@@ -8,7 +8,7 @@
8
8
  -->
9
9
  [![Documentation](https://img.shields.io/badge/docs-disco.bii.a--star.edu.sg-blue)](https://disco.bii.a-star.edu.sg/v1/docs/toolkit/guide/) [![Downloads](https://static.pepy.tech/personalized-badge/discotoolkit?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads)](https://pepy.tech/project/discotoolkit) [![PyPI version](https://img.shields.io/pypi/v/discotoolkit)](https://pypi.org/project/discotoolkit)
10
10
 
11
- # DISCOtoolkit 1.2.1
11
+ # DISCOtoolkit 1.3.0
12
12
 
13
13
  DISCOtoolkit is a Python package for accessing the data and tools of the [DISCO database](https://disco.bii.a-star.edu.sg/) (DISCO v1). Read the documentation, with tutorials and the API reference, at [disco.bii.a-star.edu.sg/v1/docs/toolkit/guide](https://disco.bii.a-star.edu.sg/v1/docs/toolkit/guide/).
14
14
 
@@ -17,7 +17,7 @@ DISCOtoolkit is a Python package for accessing the data and tools of the [DISCO
17
17
  - CELLiD: cell type annotation
18
18
  - scEnrichment: gene set enrichment using DISCO DEGs
19
19
 
20
- > **DISCO v1 and v2.** The toolkit talks to **DISCO v1** by default. DISCO v2 has its own R package ([DISCOtoolkit](https://github.com/JinmiaoChenLab/DISCOtoolkit)); the Python package can still be pointed at a v2 server, see [Choosing a server](#choosing-a-server).
20
+ > **For DISCO v1.** The toolkit is built for and tested against **DISCO v1**, which it uses by default. DISCO v2 is not supported; it has its own R package, [DISCOtoolkit](https://github.com/JinmiaoChenLab/DISCOtoolkit).
21
21
 
22
22
  ## Quickstart (Google Colab)
23
23
 
@@ -61,17 +61,17 @@ python -m ipykernel install --user --name disco --display-name "disco"
61
61
  python -m pip install -U discotoolkit
62
62
  ```
63
63
 
64
- ## Choosing a server
64
+ ## Server
65
65
 
66
66
  ```python
67
67
  import discotoolkit as dt
68
68
 
69
- dt.get_server() # 'https://disco.bii.a-star.edu.sg/disco_v3_api/' (DISCO v1, the default)
70
- dt.set_server("v2") # DISCO v2
71
- dt.set_server("https://my.server/disco_v3_api/") # any server with the same API
69
+ dt.get_server() # 'https://disco.bii.a-star.edu.sg/disco_v3_api/' (DISCO v1)
70
+ dt.set_server("https://my.mirror/disco_v3_api/") # a mirror or test copy of DISCO v1
72
71
  ```
73
72
 
74
- or set the `DISCO_API_URL` environment variable before importing the package.
73
+ or set the `DISCO_API_URL` environment variable before importing the package. The tests use this
74
+ to run against a local copy of DISCO v1.
75
75
 
76
76
  ## Testing
77
77
 
@@ -82,7 +82,7 @@ python tests/test_settings.py # offline: server selection logic
82
82
  python tests/test_version.py # offline: setup.py and __init__.py agree on the version
83
83
  python tests/test_docs.py # offline: notebooks are clean, every public function is in the API reference
84
84
  python tests/test_server_contract.py # online: does the server answer everything the toolkit needs?
85
- python tests/test_server_contract.py https://immunesinglecell.org/disco_v3_api/ # check another server
85
+ python tests/test_server_contract.py <api root> # check another server
86
86
  ```
87
87
 
88
88
  GitHub Actions runs these, and installs the package on Python 3.9-3.12, on every push. Maintainers: see [RELEASING.md](RELEASING.md) for how a release, and its documentation, is published.
@@ -2,12 +2,13 @@
2
2
  Settings shared by the rest of the package: logging, the request timeout and --
3
3
  most importantly -- which DISCO server the toolkit talks to.
4
4
 
5
- By default the toolkit talks to DISCO v1 (https://disco.bii.a-star.edu.sg). To use
6
- another server:
5
+ The toolkit is built for, and tested against, DISCO v1 (https://disco.bii.a-star.edu.sg), and
6
+ talks to it by default. DISCO v2 is not supported: it has its own R package (DISCOtoolkit).
7
+
8
+ For a mirror or a test copy of DISCO v1 there is still a way to point it elsewhere:
7
9
 
8
10
  import discotoolkit as dt
9
- dt.set_server("v2") # a named preset
10
- dt.set_server("https://my.server/disco_v3_api/") # any server with the same API
11
+ dt.set_server("https://my.mirror/disco_v3_api/")
11
12
 
12
13
  or set the DISCO_API_URL environment variable before importing the package.
13
14
  """
@@ -20,19 +21,26 @@ logging.basicConfig(level=logging.INFO)
20
21
  # seconds to wait for the server; the reference downloads are tens of MB
21
22
  timeout = 600
22
23
 
23
- # The API roots the toolkit knows by name. Both serve the same `toolkit/...` endpoints.
24
+ # The API roots the toolkit knows by name.
24
25
  SERVERS = {
25
26
  "v1": "https://disco.bii.a-star.edu.sg/disco_v3_api/",
26
- "v2": "https://immunesinglecell.org/disco_v3_api/",
27
27
  }
28
28
  DEFAULT_SERVER = "v1"
29
29
 
30
+ # Removed in 1.3.0: the toolkit was never tested against DISCO v2, which has its own R package.
31
+ _UNSUPPORTED = {
32
+ "v2": "DISCO v2 is not supported by the Python toolkit, which is built and tested for DISCO v1 "
33
+ "(the default). For DISCO v2 use its R package: https://github.com/JinmiaoChenLab/DISCOtoolkit",
34
+ }
35
+
30
36
 
31
37
  def _normalise(server: str) -> str:
32
38
  """Turn a preset name or a URL into an API root that ends with exactly one '/'."""
33
39
  if not isinstance(server, str) or not server.strip():
34
40
  raise ValueError("server must be a preset name (%s) or a URL" % ", ".join(SERVERS))
35
41
  server = server.strip()
42
+ if server.lower() in _UNSUPPORTED:
43
+ raise ValueError(_UNSUPPORTED[server.lower()])
36
44
  if server.lower() in SERVERS:
37
45
  return SERVERS[server.lower()]
38
46
  if not server.lower().startswith(("http://", "https://")):
@@ -49,8 +57,8 @@ def set_server(server: str) -> str:
49
57
  """Choose which DISCO server the toolkit uses for the rest of the session.
50
58
 
51
59
  Args:
52
- server (str): "v1", "v2", or the full URL of an API root such as
53
- "https://disco.bii.a-star.edu.sg/disco_v3_api/".
60
+ server (str): "v1" (DISCO v1, the default), or the full URL of the API root of a mirror
61
+ or test copy of DISCO v1, such as "http://127.0.0.1:8889/disco_v3_api/".
54
62
 
55
63
  Returns:
56
64
  str: the API root now in use.
@@ -5,4 +5,4 @@ from .CELLiD import *
5
5
  from .GeneSearch import *
6
6
  from .GlobalVariable import set_server, get_server
7
7
 
8
- __version__ = "1.2.1"
8
+ __version__ = "1.3.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: discotoolkit
3
- Version: 1.2.1
3
+ Version: 1.3.0
4
4
  Summary: DISCOtoolkit is an python package that allows users to access data and use the tools provided by the DISCO database.
5
5
  Home-page: https://disco.bii.a-star.edu.sg/
6
6
  Author: Li Mengwei, Rom Uddamvathanak
@@ -43,7 +43,7 @@ Dynamic: summary
43
43
  -->
44
44
  [![Documentation](https://img.shields.io/badge/docs-disco.bii.a--star.edu.sg-blue)](https://disco.bii.a-star.edu.sg/v1/docs/toolkit/guide/) [![Downloads](https://static.pepy.tech/personalized-badge/discotoolkit?period=total&units=international_system&left_color=black&right_color=orange&left_text=Downloads)](https://pepy.tech/project/discotoolkit) [![PyPI version](https://img.shields.io/pypi/v/discotoolkit)](https://pypi.org/project/discotoolkit)
45
45
 
46
- # DISCOtoolkit 1.2.1
46
+ # DISCOtoolkit 1.3.0
47
47
 
48
48
  DISCOtoolkit is a Python package for accessing the data and tools of the [DISCO database](https://disco.bii.a-star.edu.sg/) (DISCO v1). Read the documentation, with tutorials and the API reference, at [disco.bii.a-star.edu.sg/v1/docs/toolkit/guide](https://disco.bii.a-star.edu.sg/v1/docs/toolkit/guide/).
49
49
 
@@ -52,7 +52,7 @@ DISCOtoolkit is a Python package for accessing the data and tools of the [DISCO
52
52
  - CELLiD: cell type annotation
53
53
  - scEnrichment: gene set enrichment using DISCO DEGs
54
54
 
55
- > **DISCO v1 and v2.** The toolkit talks to **DISCO v1** by default. DISCO v2 has its own R package ([DISCOtoolkit](https://github.com/JinmiaoChenLab/DISCOtoolkit)); the Python package can still be pointed at a v2 server, see [Choosing a server](#choosing-a-server).
55
+ > **For DISCO v1.** The toolkit is built for and tested against **DISCO v1**, which it uses by default. DISCO v2 is not supported; it has its own R package, [DISCOtoolkit](https://github.com/JinmiaoChenLab/DISCOtoolkit).
56
56
 
57
57
  ## Quickstart (Google Colab)
58
58
 
@@ -96,17 +96,17 @@ python -m ipykernel install --user --name disco --display-name "disco"
96
96
  python -m pip install -U discotoolkit
97
97
  ```
98
98
 
99
- ## Choosing a server
99
+ ## Server
100
100
 
101
101
  ```python
102
102
  import discotoolkit as dt
103
103
 
104
- dt.get_server() # 'https://disco.bii.a-star.edu.sg/disco_v3_api/' (DISCO v1, the default)
105
- dt.set_server("v2") # DISCO v2
106
- dt.set_server("https://my.server/disco_v3_api/") # any server with the same API
104
+ dt.get_server() # 'https://disco.bii.a-star.edu.sg/disco_v3_api/' (DISCO v1)
105
+ dt.set_server("https://my.mirror/disco_v3_api/") # a mirror or test copy of DISCO v1
107
106
  ```
108
107
 
109
- or set the `DISCO_API_URL` environment variable before importing the package.
108
+ or set the `DISCO_API_URL` environment variable before importing the package. The tests use this
109
+ to run against a local copy of DISCO v1.
110
110
 
111
111
  ## Testing
112
112
 
@@ -117,7 +117,7 @@ python tests/test_settings.py # offline: server selection logic
117
117
  python tests/test_version.py # offline: setup.py and __init__.py agree on the version
118
118
  python tests/test_docs.py # offline: notebooks are clean, every public function is in the API reference
119
119
  python tests/test_server_contract.py # online: does the server answer everything the toolkit needs?
120
- python tests/test_server_contract.py https://immunesinglecell.org/disco_v3_api/ # check another server
120
+ python tests/test_server_contract.py <api root> # check another server
121
121
  ```
122
122
 
123
123
  GitHub Actions runs these, and installs the package on Python 3.9-3.12, on every push. Maintainers: see [RELEASING.md](RELEASING.md) for how a release, and its documentation, is published.
@@ -19,6 +19,7 @@ discotoolkit.egg-info/requires.txt
19
19
  discotoolkit.egg-info/top_level.txt
20
20
  tests/test_docs.py
21
21
  tests/test_gene_search.py
22
+ tests/test_metadata_helpers.py
22
23
  tests/test_reference_loading.py
23
24
  tests/test_server_contract.py
24
25
  tests/test_settings.py
@@ -6,7 +6,7 @@ with open("requirements.txt", "r") as f:
6
6
 
7
7
  setup(
8
8
  name='discotoolkit',
9
- version="1.2.1",
9
+ version="1.3.0",
10
10
  url='https://disco.bii.a-star.edu.sg/',
11
11
  author='Li Mengwei, Rom Uddamvathanak',
12
12
  author_email='uddamvathanak_rom@immunol.a-star.edu.sg',
@@ -72,6 +72,28 @@ def test_api_reference_names_only_things_that_exist():
72
72
  assert re.search(r"^(def|class)\s+%s\b" % name, source, re.M), "%s.%s is gone" % (module, name)
73
73
 
74
74
 
75
+ def test_tutorials_link_to_pages_not_to_notebook_files_and_not_to_the_v2_site():
76
+ problems = []
77
+ for path in sorted(glob.glob(os.path.join(ROOT, "docs", "*.ipynb"))):
78
+ text = "\n".join("".join(c["source"]) for c in json.load(open(path, encoding="utf-8"))["cells"])
79
+ name = os.path.basename(path)
80
+ # a relative link to another .ipynb works on GitHub but is a dead link on the site
81
+ for target in re.findall(r"\]\(([^)\s]+)\)", text):
82
+ if target.endswith(".ipynb") and not target.startswith("http"):
83
+ problems.append("%s links to the file %s; link to the page on the docs site" % (name, target))
84
+ if "immunesinglecell.org" in text:
85
+ problems.append("%s sends readers to the DISCO V2 site; V1 is the supported server" % name)
86
+ assert not problems, "; ".join(problems)
87
+
88
+
89
+ def test_the_changelog_has_notes_for_the_current_version():
90
+ # the release workflow builds the GitHub Release text from it, and refuses a version without notes
91
+ version = re.search(r'__version__\s*=\s*"([^"]+)"', read("discotoolkit/__init__.py")).group(1)
92
+ assert re.search(r"^## %s\b" % re.escape(version), read("CHANGELOG.md"), re.M), (
93
+ "add a '## %s' section to CHANGELOG.md before releasing" % version
94
+ )
95
+
96
+
75
97
  def _run_all():
76
98
  tests = [(n, f) for n, f in sorted(globals().items()) if n.startswith("test_") and callable(f)]
77
99
  failed = 0
@@ -0,0 +1,49 @@
1
+ """
2
+ The metadata helpers people use to discover what they can filter on: list_all_columns and
3
+ list_metadata_item. No network: the metadata table is faked.
4
+
5
+ python tests/test_metadata_helpers.py
6
+ """
7
+ import os
8
+ import sys
9
+ from unittest import mock
10
+
11
+ import pandas as pd
12
+
13
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
14
+ from discotoolkit import GetMetadata # noqa: E402
15
+
16
+ TABLE = pd.DataFrame({
17
+ "sample_id": ["S1", "S2", "S3"],
18
+ "tissue": ["lung", "lung", "blood"],
19
+ "platform": ["10x3'", "10x5'", "10x3'"],
20
+ })
21
+
22
+
23
+ def test_list_all_columns_names_every_metadata_field():
24
+ with mock.patch.object(GetMetadata, "get_disco_metadata", return_value=TABLE):
25
+ assert GetMetadata.list_all_columns() == ["sample_id", "tissue", "platform"]
26
+
27
+
28
+ def test_list_metadata_item_gives_each_value_once():
29
+ with mock.patch.object(GetMetadata, "get_disco_metadata", return_value=TABLE):
30
+ assert sorted(GetMetadata.list_metadata_item("platform")) == ["10x3'", "10x5'"]
31
+ assert GetMetadata.list_metadata_item("no_such_field") is None
32
+
33
+
34
+ def _run_all():
35
+ tests = [(n, f) for n, f in sorted(globals().items()) if n.startswith("test_") and callable(f)]
36
+ failed = 0
37
+ for name, fn in tests:
38
+ try:
39
+ fn()
40
+ print(" PASS %s" % name)
41
+ except Exception as error:
42
+ failed += 1
43
+ print(" FAIL %s\n %s: %s" % (name, type(error).__name__, error))
44
+ print("\n%d/%d passed" % (len(tests) - failed, len(tests)))
45
+ return 1 if failed else 0
46
+
47
+
48
+ if __name__ == "__main__":
49
+ sys.exit(_run_all())
@@ -5,7 +5,7 @@ Needs only `requests`, so it runs anywhere -- including a fresh Colab notebook:
5
5
 
6
6
  !pip install requests
7
7
  !python tests/test_server_contract.py # DISCO v1 (default)
8
- !python tests/test_server_contract.py https://immunesinglecell.org/disco_v3_api/ # another server
8
+ !python tests/test_server_contract.py <api root> # another server
9
9
 
10
10
  or with pytest: DISCO_API_URL=<api root> pytest tests/test_server_contract.py
11
11
 
@@ -41,15 +41,29 @@ def test_api_url_joins_paths_with_exactly_one_slash():
41
41
  assert g.api_url("/toolkit/getSampleMetadata") == g.get_server() + "toolkit/getSampleMetadata"
42
42
 
43
43
 
44
- def test_named_presets_and_urls():
44
+ def test_v1_preset_and_urls_of_a_mirror():
45
45
  g = load()
46
- assert g.set_server("v2") == "https://immunesinglecell.org/disco_v3_api/"
47
- assert g.api_url("x") == "https://immunesinglecell.org/disco_v3_api/x" # takes effect at once
46
+ assert g.set_server("http://127.0.0.1:8889/disco_v3_api") == "http://127.0.0.1:8889/disco_v3_api/"
47
+ assert g.api_url("x") == "http://127.0.0.1:8889/disco_v3_api/x" # takes effect at once
48
48
  assert g.set_server("V1") == g.SERVERS["v1"] # preset names are case-insensitive
49
49
  assert g.set_server("https://example.org/api") == "https://example.org/api/" # trailing slash added
50
50
  assert g.set_server("http://localhost:8889/disco_v3_api///") == "http://localhost:8889/disco_v3_api/"
51
51
 
52
52
 
53
+ def test_disco_v2_is_refused_with_a_pointer_to_the_r_package():
54
+ g = load()
55
+ before = g.get_server()
56
+ for name in ("v2", "V2"):
57
+ try:
58
+ g.set_server(name)
59
+ except ValueError as error:
60
+ assert "R package" in str(error) and "DISCOtoolkit" in str(error), error
61
+ else:
62
+ raise AssertionError("set_server(%r) was accepted" % name)
63
+ assert g.get_server() == before
64
+ assert list(g.SERVERS) == ["v1"]
65
+
66
+
53
67
  def test_bad_servers_are_rejected_without_changing_the_current_one():
54
68
  g = load()
55
69
  before = g.get_server()
@@ -64,14 +78,20 @@ def test_bad_servers_are_rejected_without_changing_the_current_one():
64
78
 
65
79
 
66
80
  def test_environment_variable_sets_the_starting_server():
67
- assert load("v2").get_server() == "https://immunesinglecell.org/disco_v3_api/"
68
81
  assert load("https://example.org/disco_v3_api").get_server() == "https://example.org/disco_v3_api/"
82
+ # asking for v2 through the environment fails loudly rather than quietly using v1
83
+ try:
84
+ load("v2")
85
+ except ValueError:
86
+ pass
87
+ else:
88
+ raise AssertionError("DISCO_API_URL=v2 was accepted")
69
89
 
70
90
 
71
91
  def test_old_prefix_variable_still_readable():
72
92
  g = load()
73
- g.set_server("v2")
74
- assert g.prefix_disco_url == "https://immunesinglecell.org/disco_v3_api/"
93
+ g.set_server("https://example.org/disco_v3_api/")
94
+ assert g.prefix_disco_url == "https://example.org/disco_v3_api/"
75
95
 
76
96
 
77
97
  def _run_all():
File without changes
File without changes