repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.logout_request import OneLogin_Saml2_Logout_Request from onelogin.saml2.settings import OneLogin_Saml2_Settings from onelogin.saml2.utils import OneLogin_S...
name_id_data_3)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/logout_request_test.py
testGetNameIdData
OneLogin_Saml2_Logout_Request_Test
216
null
SAML-Toolkits/python3-saml
""" Tests the get_self_url_host method of the OneLogin_Saml2_Utils """ request_data = {"http_host": "example.com"} self.assertEqual("http://example.com", OneLogin_Saml2_Utils.get_self_url_host(request_data)) if sys.version_info > (3, 2, 0): with self.assertWa...
str(e))
self.assertEqual
func_call
tests/src/OneLogin/saml2_tests/utils_test.py
testValidateSign
OneLogin_Saml2_Utils_Test
799
null
SAML-Toolkits/python3-saml
import unittest from pyramid import testing class ViewTests(unittest.TestCase): def setUp(self): self.config = testing.setUp() def tearDown(self): testing.tearDown() def test_my_view(self): from .views import my_view request = testing.DummyRequest() info = my_vie...
"demo_pyramid")
self.assertEqual
string_literal
demo_pyramid/demo_pyramid/tests.py
test_my_view
ViewTests
18
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.logout_request import OneLogin_Saml2_Logout_Request from onelogin.saml2.settings import OneLogin_Saml2_Settings from onelogin.saml2.utils import OneLogin_S...
name_id_data_4)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/logout_request_test.py
testGetNameIdData
OneLogin_Saml2_Logout_Request_Test
194
null
SAML-Toolkits/python3-saml
from base64 import b64decode from lxml import etree import json import sys from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.errors import OneLogin_Saml2_ValidationError from onelogin.saml2.response import OneLogin_S...
pretty_xml)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/response_test.py
testGetXMLDocument
OneLogin_Saml2_Response_Test
83
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.logout_response import OneLogin_Saml2_Logout_Response from onelogin.saml2.settings import One...
response_3.is_valid(request_data))
self.assertTrue
func_call
tests/src/OneLogin/saml2_tests/logout_response_test.py
testIsInValidDestination
OneLogin_Saml2_Logout_Response_Test
224
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.logout_response import OneLogin_Saml2_Logout_Response from onelogin.saml2.settings import One...
response_2.get_error())
self.assertIn
func_call
tests/src/OneLogin/saml2_tests/logout_response_test.py
testIsInValidRequestId
OneLogin_Saml2_Logout_Response_Test
172
null
SAML-Toolkits/python3-saml
message = OneLogin_Saml2_Utils.b64encode(plain_message) xml_2 = self.file_contents(join(self.data_path, "responses", "invalids", "no_subjectconfirmation_data.xml.base64")) plain_message_2 = compat.to_string(OneLogin_Saml2_Utils.b64decode(xml_2)) plain_message_2 = plain_message_2.replace...
2671081021)
self.assertEqual
numeric_literal
tests/src/OneLogin/saml2_tests/response_test.py
testGetAssertionNotOnOrAfter
OneLogin_Saml2_Response_Test
1,870
null
SAML-Toolkits/python3-saml
from base64 import b64decode import json from lxml import etree from os.path import dirname, join, exists import unittest import sys from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.settings import OneLogin_Saml2...
Exception)
self.assertRaises
variable
tests/src/OneLogin/saml2_tests/utils_test.py
testRedirect
OneLogin_Saml2_Utils_Test
129
null
SAML-Toolkits/python3-saml
import unittest from onelogin.saml2.errors import OneLogin_Saml2_Error class OneLogin_Saml2_Error_Test(unittest.TestCase): def runTest(self): exception = OneLogin_Saml2_Error("test") self.assertEqual(str(exception),
"test")
self.assertEqual
string_literal
tests/src/OneLogin/saml2_tests/error_test.py
runTest
OneLogin_Saml2_Error_Test
15
null
SAML-Toolkits/python3-saml
import json import unittest import xmlsec from base64 import b64decode from lxml import etree from os.path import dirname, join, exists from onelogin.saml2.utils import OneLogin_Saml2_XML class TestOneLoginSaml2Xml(unittest.TestCase): data_path = join(dirname(__file__), "..", "..", "..", "data") def loadSett...
assertion.tag)
self.assertIn
complex_expr
tests/src/OneLogin/saml2_tests/xml_utils_test.py
testQuery
TestOneLoginSaml2Xml
131
null
SAML-Toolkits/python3-saml
from urllib.error import URLError from copy import deepcopy import json from os.path import dirname, join, exists from lxml.etree import XMLSyntaxError import unittest from onelogin.saml2.idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser from onelogin.saml2.constants import OneLogin_Saml2_Constants class O...
settings5)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/idp_metadata_parser_test.py
test_parse_required_binding_all
OneLogin_Saml2_IdPMetadataParser_Test
258
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists, sep import unittest from onelogin.saml2 import compat from onelogin.saml2.errors import OneLogin_Saml2_Error from onelogin.saml2.settings import OneLogin_Saml2_Settings from onelogin.saml2.utils import OneLogin_Saml2_Utils class OneLogin_Saml2_Settings_Test(unitt...
0)
self.assertEqual
numeric_literal
tests/src/OneLogin/saml2_tests/settings_test.py
testLoadSettingsFromDict
OneLogin_Saml2_Settings_Test
41
null
SAML-Toolkits/python3-saml
import json import unittest import xmlsec from base64 import b64decode from lxml import etree from os.path import dirname, join, exists from onelogin.saml2.utils import OneLogin_Saml2_XML class TestOneLoginSaml2Xml(unittest.TestCase): data_path = join(dirname(__file__), "..", "..", "..", "data") def loadSett...
ValueError)
self.assertRaises
variable
tests/src/OneLogin/saml2_tests/xml_utils_test.py
testToString
TestOneLoginSaml2Xml
88
null
SAML-Toolkits/python3-saml
from base64 import b64decode import json from lxml import etree from os.path import dirname, join, exists import unittest import sys from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.settings import OneLogin_Saml2...
848)
self.assertEqual
numeric_literal
tests/src/OneLogin/saml2_tests/utils_test.py
testFormatPrivateKey
OneLogin_Saml2_Utils_Test
92
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.logout_response import OneLogin_Saml2_Logout_Response from onelogin.saml2.settings import One...
Exception)
self.assertRaises
variable
tests/src/OneLogin/saml2_tests/logout_response_test.py
testIsValidRaisesExceptionWhenRaisesArgumentIsTrue
OneLogin_Saml2_Logout_Response_Test
340
null
SAML-Toolkits/python3-saml
from base64 import b64decode from lxml import etree import json import sys from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.errors import OneLogin_Saml2_ValidationError from onelogin.saml2.response import OneLogin_S...
response.get_error())
self.assertEqual
func_call
tests/src/OneLogin/saml2_tests/response_test.py
testCheckOneCondition
OneLogin_Saml2_Response_Test
538
null
SAML-Toolkits/python3-saml
import json import unittest import xmlsec from base64 import b64decode from lxml import etree from os.path import dirname, join, exists from onelogin.saml2.utils import OneLogin_Saml2_XML class TestOneLoginSaml2Xml(unittest.TestCase): data_path = join(dirname(__file__), "..", "..", "..", "data") def loadSett...
str(exception))
self.assertIn
func_call
tests/src/OneLogin/saml2_tests/xml_utils_test.py
testToString
TestOneLoginSaml2Xml
91
null
SAML-Toolkits/python3-saml
from urllib.error import URLError from copy import deepcopy import json from os.path import dirname, join, exists from lxml.etree import XMLSyntaxError import unittest from onelogin.saml2.idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser from onelogin.saml2.constants import OneLogin_Saml2_Constants class O...
data2)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/idp_metadata_parser_test.py
test_parse_with_entity_id
OneLogin_Saml2_IdPMetadataParser_Test
327
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists from time import strftime from datetime import datetime, timezone import unittest from onelogin.saml2 import compat from onelogin.saml2.metadata import OneLogin_Saml2_Metadata from onelogin.saml2.settings import OneLogin_Saml2_Settings from onelogin.saml2.constants...
Exception)
self.assertRaises
variable
tests/src/OneLogin/saml2_tests/metadata_test.py
testSignMetadata
OneLogin_Saml2_Metadata_Test
188
null
SAML-Toolkits/python3-saml
import unittest from pyramid import testing class FunctionalTests(unittest.TestCase): def setUp(self): from demo_pyramid import main app = main({}) from webtest import TestApp self.testapp = TestApp(app) def test_root(self): res = self.testapp.get("/", status=200) ...
b"Pyramid" in res.body)
self.assertTrue
string_literal
demo_pyramid/demo_pyramid/tests.py
test_root
FunctionalTests
32
null
SAML-Toolkits/python3-saml
from base64 import b64decode, b64encode import json from os.path import dirname, join, exists import unittest from onelogin.saml2 import compat from onelogin.saml2.auth import OneLogin_Saml2_Auth from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.settings import OneLogin_Saml2_Settings f...
0)
self.assertEqual
numeric_literal
tests/src/OneLogin/saml2_tests/auth_test.py
testProcessResponseInvalid
OneLogin_Saml2_Auth_Test
174
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from onelogin.saml2.response import OneLogin_Saml2_Response from onelogin.saml2.settings import OneLogin_Saml2_Settings from onelogin.saml2.utils import OneLogin_Saml2_Utils class OneLogin_Saml2_SignedResponse_Test(unittest.TestCase): data_path...
response.get_nameid())
self.assertEqual
func_call
tests/src/OneLogin/saml2_tests/signed_response_test.py
testResponseSignedAssertionNot
OneLogin_Saml2_SignedResponse_Test
41
null
SAML-Toolkits/python3-saml
import json import unittest import xmlsec from base64 import b64decode from lxml import etree from os.path import dirname, join, exists from onelogin.saml2.utils import OneLogin_Saml2_XML class TestOneLoginSaml2Xml(unittest.TestCase): data_path = join(dirname(__file__), "..", "..", "..", "data") def loadSett...
OneLogin_Saml2_XML.to_string(xml))
self.assertIs
func_call
tests/src/OneLogin/saml2_tests/xml_utils_test.py
testToString
TestOneLoginSaml2Xml
85
null
SAML-Toolkits/python3-saml
import json import unittest import xmlsec from base64 import b64decode from lxml import etree from os.path import dirname, join, exists from onelogin.saml2.utils import OneLogin_Saml2_XML class TestOneLoginSaml2Xml(unittest.TestCase): data_path = join(dirname(__file__), "..", "..", "..", "data") def loadSett...
elem)
self.assertIs
variable
tests/src/OneLogin/saml2_tests/xml_utils_test.py
testToElement
TestOneLoginSaml2Xml
113
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.logout_response import OneLogin_Saml2_Logout_Response from onelogin.saml2.settings import One...
issuer_2)
self.assertIsNone
variable
tests/src/OneLogin/saml2_tests/logout_response_test.py
testGetIssuer
OneLogin_Saml2_Logout_Response_Test
120
null
SAML-Toolkits/python3-saml
from base64 import b64decode import json from lxml import etree from os.path import dirname, join, exists import unittest import sys from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.settings import OneLogin_Saml2...
924)
self.assertEqual
numeric_literal
tests/src/OneLogin/saml2_tests/utils_test.py
testFormatPrivateKey
OneLogin_Saml2_Utils_Test
98
null
SAML-Toolkits/python3-saml
target_url = auth.login(return_to) parsed_query = parse_qs(urlparse(target_url)[4]) self.assertIn(sso_url, target_url) self.assertIn("SAMLRequest", parsed_query) request = compat.to_string(OneLogin_Saml2_Utils.decode_base64_and_inflate(parsed_query["SAMLRequest"][0])) sel...
id2)
self.assertNotEqual
variable
tests/src/OneLogin/saml2_tests/auth_test.py
testGetLastRequestID
OneLogin_Saml2_Auth_Test
1,320
null
SAML-Toolkits/python3-saml
import json import unittest import xmlsec from base64 import b64decode from lxml import etree from os.path import dirname, join, exists from onelogin.saml2.utils import OneLogin_Saml2_XML class TestOneLoginSaml2Xml(unittest.TestCase): data_path = join(dirname(__file__), "..", "..", "..", "data") def loadSett...
signature_res.tag)
self.assertIn
complex_expr
tests/src/OneLogin/saml2_tests/xml_utils_test.py
testQuery
TestOneLoginSaml2Xml
146
null
SAML-Toolkits/python3-saml
from base64 import b64decode import json from lxml import etree from os.path import dirname, join, exists import unittest import sys from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.settings import OneLogin_Saml2...
self_host)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/utils_test.py
testGetselfhost
OneLogin_Saml2_Utils_Test
176
null
SAML-Toolkits/python3-saml
from urllib.error import URLError from copy import deepcopy import json from os.path import dirname, join, exists from lxml.etree import XMLSyntaxError import unittest from onelogin.saml2.idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser from onelogin.saml2.constants import OneLogin_Saml2_Constants class O...
settings2)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/idp_metadata_parser_test.py
test_parse_testshib_required_binding_sso_redirect
OneLogin_Saml2_IdPMetadataParser_Test
171
null
SAML-Toolkits/python3-saml
from urllib.error import URLError from copy import deepcopy import json from os.path import dirname, join, exists from lxml.etree import XMLSyntaxError import unittest from onelogin.saml2.idp_metadata_parser import OneLogin_Saml2_IdPMetadataParser from onelogin.saml2.constants import OneLogin_Saml2_Constants class O...
settings1)
self.assertEqual
variable
tests/src/OneLogin/saml2_tests/idp_metadata_parser_test.py
test_parse_testshib_required_binding_sso_redirect
OneLogin_Saml2_IdPMetadataParser_Test
170
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.constants import OneLogin_Saml2_Constants from onelogin.saml2.logout_response import OneLogin_Saml2_Logout_Response from onelogin.saml2.settings import One...
"^<samlp:LogoutResponse")
self.assertRegex
string_literal
tests/src/OneLogin/saml2_tests/logout_response_test.py
testCreateDeflatedSAMLLogoutResponseURLParameter
OneLogin_Saml2_Logout_Response_Test
82
null
SAML-Toolkits/python3-saml
import json from os.path import dirname, join, exists import unittest from xml.dom.minidom import parseString from onelogin.saml2 import compat from onelogin.saml2.logout_request import OneLogin_Saml2_Logout_Request from onelogin.saml2.settings import OneLogin_Saml2_Settings from onelogin.saml2.utils import OneLogin_S...
issuer_3)
self.assertIsNone
variable
tests/src/OneLogin/saml2_tests/logout_request_test.py
testGetIssuer
OneLogin_Saml2_Logout_Request_Test
261
null
DHI/terracotta
from marshmallow import ValidationError import pytest from terracotta.server.singleband import SinglebandOptionSchema from terracotta.server.rgb import RGBOptionSchema def test_serde_validation(): option_schema = SinglebandOptionSchema() with pytest.raises(ValidationError) as exc_info: args = {"stretc...
str(exc_info.value)
assert
func_call
tests/server/test_fields.py
test_serde_validation
26
null
DHI/terracotta
from PIL import Image import numpy as np import pytest from terracotta import exceptions def test_rgb_color_transform_valid(use_testdb): from terracotta.handlers import rgb ds_keys = ["val21", "x", "val22"] bands = ["val22", "val23", "val24"] tile_raw_no_transform = rgb.rgb(ds_keys[:2], bands) ...
tile_identity_transform)
assert_*
variable
tests/handlers/test_rgb.py
test_rgb_color_transform_valid
241
null
DHI/terracotta
import pytest TESTABLE_DRIVERS = ["sqlite", "mysql", "postgresql"] DRIVER_CLASSES = { "sqlite": "SQLiteMetaStore", "sqlite-remote": "SQLiteRemoteMetaStore", "mysql": "MySQLMetaStore", "postgresql": "PostgreSQLMetaStore", } @pytest.mark.parametrize("provider", ["sqlite"]) def test_normalize_filepath(pr...
first_path
assert
variable
tests/drivers/test_drivers.py
test_normalize_filepath
44
null
DHI/terracotta
import pytest import time from moto import mock_aws from moto.xray import XRaySegment @mock_aws def run_test(): from terracotta import update_settings import terracotta.profile update_settings(XRAY_PROFILE=True) with XRaySegment(): with pytest.raises(
NotImplementedError)
pytest.raises
variable
tests/test_profile.py
run_test
49
null
DHI/terracotta
import pytest import numpy as np def reload_cmap(): import importlib import terracotta.cmaps.get_cmaps try: yield finally: importlib.reload(terracotta.cmaps.get_cmaps) def test_get_cmap(): from terracotta.cmaps.get_cmaps import get_cmap, AVAILABLE_CMAPS for name in AVAILABLE...
(255, 4)
assert
collection
tests/cmaps/test_get_cmap.py
test_get_cmap
22
null
DHI/terracotta
import zlib import numpy as np def test_get_size(): from terracotta.cache import CompressedLFUCache tile_shape = (256, 256) data = zlib.compress(np.ones(tile_shape), 9) mask = zlib.compress(np.zeros(tile_shape), 9) size = CompressedLFUCache._get_size((data, mask, "float64", tile_shape)) asse...
size
assert
variable
tests/test_cache.py
test_get_size
13
null
DHI/terracotta
from marshmallow import ValidationError import pytest from terracotta.server.singleband import SinglebandOptionSchema from terracotta.server.rgb import RGBOptionSchema def test_serde_validation(): option_schema = SinglebandOptionSchema() with pytest.raises(
ValidationError)
pytest.raises
variable
tests/server/test_fields.py
test_serde_validation
23
null
DHI/terracotta
import json import pytest def test_schema_integrity(): from terracotta import config settings_fields = config.TerracottaSettings._fields schema_fields = config.SettingSchema._declared_fields assert set(settings_fields) ==
set(schema_fields)
assert
func_call
tests/test_config.py
test_schema_integrity
11
null
DHI/terracotta
import pytest import numpy as np import rasterio import rasterio.features from shapely.geometry import shape, MultiPolygon def geometry_mismatch(shape1, shape2): """Compute relative mismatch of two shapes""" return shape1.symmetric_difference(shape2).area / shape1.union(shape2).area def convex_hull_exact(src...
tile_size
assert
variable
tests/test_raster.py
test_get_raster_no_nodata
269
null
DHI/terracotta
import pytest from click.testing import CliRunner import os import shutil TEST_CASES = ( { # basic "filenames": ["foo.tif"], "input_pattern": "{name}.tif", "expected_keys": ["name"], "expected_datasets": [("foo",)], }, { # two keys "filenames": ["S2_20180101_B04.t...
0
assert
numeric_literal
tests/scripts/test_ingest.py
test_ingest
121
null
DHI/terracotta
import numpy as np from PIL import Image import pytest @pytest.mark.parametrize("stretch_range", [[0, 0.1], [20000, 30000], [-50000, 50000]]) def test_colormap_range(stretch_range): """Ensure that all colors from colormap file are present in returned data""" from terracotta.cmaps import get_cmap from terr...
cmap_out_arr)
assert_*
variable
tests/handlers/test_colormap.py
test_colormap_range
91
null
DHI/terracotta
import pytest import sys from textwrap import dedent import numpy as np OPERANDS = { "v1": np.ma.masked_array(np.arange(1, 6), dtype="float64"), "v2": np.ma.masked_array( 2 * np.arange(1, 6), dtype="float64", mask=np.array([1, 1, 1, 0, 0]) ), } VALID_EXPR = ( # identity ("v1", OPERANDS["...
RuntimeError)
pytest.raises
variable
tests/test_expressions.py
test_timeout
195
null
DHI/terracotta
import pytest from PIL import Image import numpy as np def test_apply_color_operation(): from terracotta import image data = np.array([0, 0.2, 0.5, 1]) color_transform = "gamma 1 1" np.testing.assert_array_equal(
data)
assert_*
variable
tests/test_image.py
test_apply_color_operation
116
null
DHI/terracotta
from PIL import Image import numpy as np def test_compute_handler(use_testdb, raster_file_xyz): import terracotta from terracotta.handlers import compute settings = terracotta.get_settings() raw_img = compute.compute( "v1 + v2", ["val21", "x"], {"v1": "val22", "v2": "val23"}, ...
settings.DEFAULT_TILE_SIZE
assert
complex_expr
tests/handlers/test_compute.py
test_compute_handler
19
null
DHI/terracotta
from PIL import Image import numpy as np import pytest from terracotta import exceptions @pytest.mark.parametrize( "stretch_range_params", [ ["s2", "p98", "Invalid scale value"], ["pp2", "p98", "Invalid percentile value"], ["p", "p98", "Invalid percentile value"], ["2", "p8", ...
str(err.value)
assert
func_call
tests/handlers/test_rgb.py
test_rgb_invalid_percentiles
215
null
DHI/terracotta
import pytest import numpy as np import rasterio import rasterio.features from shapely.geometry import shape, MultiPolygon def geometry_mismatch(shape1, shape2): """Compute relative mismatch of two shapes""" return shape1.symmetric_difference(shape2).area / shape1.union(shape2).area def convex_hull_exact(src...
ValueError)
pytest.raises
variable
tests/test_raster.py
test_invalid_resampling_method
275
null
DHI/terracotta
import json import pytest def test_env_config(monkeypatch): from terracotta import config with monkeypatch.context() as m: m.setenv("TC_DRIVER_PATH", "test") assert config.parse_config().DRIVER_PATH == "test" with monkeypatch.context() as m: m.setenv("TC_DRIVER_PATH", "test2") ...
"test2"
assert
string_literal
tests/test_config.py
test_env_config
23
null
DHI/terracotta
from PIL import Image import numpy as np import pytest from terracotta import exceptions def test_rgb_handler(use_testdb, raster_file, raster_file_xyz): import terracotta from terracotta.handlers import rgb raw_img = rgb.rgb(["val21", "x"], ["val22", "val23", "val24"], raster_file_xyz) img_data = np...
(*terracotta.get_settings().DEFAULT_TILE_SIZE, 3)
assert
collection
tests/handlers/test_rgb.py
test_rgb_handler
15
null
DHI/terracotta
import pytest import numpy as np def reload_cmap(): import importlib import terracotta.cmaps.get_cmaps try: yield finally: importlib.reload(terracotta.cmaps.get_cmaps) def test_extra_cmap_invalid_shape(monkeypatch, tmpdir): import importlib import terracotta.cmaps.get_cmaps ...
str(raised_exc.value)
assert
func_call
tests/cmaps/test_get_cmap.py
test_extra_cmap_invalid_shape
85
null
DHI/terracotta
import pytest from click.testing import CliRunner import os import shutil TEST_CASES = ( { # basic "filenames": ["foo.tif"], "input_pattern": "{name}.tif", "expected_keys": ["name"], "expected_datasets": [("foo",)], }, { # two keys "filenames": ["S2_20180101_B04.t...
{("img",): str(raster_file)}
assert
collection
tests/scripts/test_ingest.py
test_ingest
128
null
DHI/terracotta
from PIL import Image import numpy as np import pytest from terracotta import exceptions @pytest.mark.parametrize( "stretch_range_params", [ ["s2", "p98", "Invalid scale value"], ["pp2", "p98", "Invalid percentile value"], ["p", "p98", "Invalid percentile value"], ["2", "p8", ...
exceptions.InvalidArgumentsError)
pytest.raises
complex_expr
tests/handlers/test_rgb.py
test_rgb_invalid_percentiles
208
null
DHI/terracotta
import pytest from click.testing import CliRunner @pytest.mark.parametrize("level", ["debug", "info"]) def test_logging_visible(level): from terracotta.scripts.cli import cli @cli.command("dummy") def dummy(): import logging logger = logging.getLogger("terracotta") logger.info("te...
0
assert
numeric_literal
tests/scripts/test_cli.py
test_logging_visible
18
null
DHI/terracotta
from click.testing import CliRunner def parse_version(verstr): """Convert 'v<major>.<minor>.<patch>' to (major, minor, patch)""" components = verstr.split(".") components[0] = components[0].lstrip("v") return tuple(int(c) for c in components[:3]) def migration_testfunc(v07_db, raster_file): import...
None
assert
none_literal
tests/scripts/test_migrate.py
migration_testfunc
47
null
DHI/terracotta
import pytest from click.testing import CliRunner @pytest.mark.parametrize("level", ["debug", "info"]) def test_logging_visible(level): from terracotta.scripts.cli import cli @cli.command("dummy") def dummy(): import logging logger = logging.getLogger("terracotta") logger.info("te...
result.output
assert
complex_expr
tests/scripts/test_cli.py
test_logging_visible
19
null
DHI/terracotta
import pytest import numpy as np import rasterio import rasterio.features from shapely.geometry import shape, MultiPolygon def geometry_mismatch(shape1, shape2): """Compute relative mismatch of two shapes""" return shape1.symmetric_difference(shape2).area / shape1.union(shape2).area def convex_hull_exact(src...
str(exc)
assert
func_call
tests/test_raster.py
test_invalid_resampling_method
277
null
DHI/terracotta
import pytest import numpy as np import rasterio import rasterio.features from shapely.geometry import shape, MultiPolygon def geometry_mismatch(shape1, shape2): """Compute relative mismatch of two shapes""" return shape1.symmetric_difference(shape2).area / shape1.union(shape2).area def convex_hull_exact(src...
valid_data.mean())
assert_*
func_call
tests/test_raster.py
test_compute_metadata
85
null
DHI/terracotta
import os import warnings import traceback import rasterio import numpy as np from click.testing import CliRunner import pytest def format_exception(result): return "".join(traceback.format_exception(*result.exc_info)) def tiny_raster_file(unoptimized_raster_file, tmpdir_factory): tmpdir = tmpdir_factory.m...
result.output
assert
complex_expr
tests/scripts/test_optimize_rasters.py
test_optimize_rasters_nofiles
119
null
DHI/terracotta
import os import tempfile import time import uuid from pathlib import Path import pytest from terracotta import exceptions boto3 = pytest.importorskip("boto3") moto = pytest.importorskip("moto") def mock_aws_env(monkeypatch): with monkeypatch.context() as m: m.setenv("AWS_DEFAULT_REGION", "us-east-1") ...
captured.err
assert
complex_expr
tests/drivers/test_sqlite_remote.py
test_destructor
174
null
DHI/terracotta
import pytest from click.testing import CliRunner def test_entrypoint(monkeypatch, capsys): import sys from terracotta.scripts.cli import entrypoint with monkeypatch.context() as m: m.setattr(sys, "argv", ["terracotta"]) with pytest.raises(
SystemExit)
pytest.raises
variable
tests/scripts/test_cli.py
test_entrypoint
45
null
DHI/terracotta
import pytest from PIL import Image import numpy as np def test_array_to_png_rgb(): from terracotta import image testdata = np.random.randint(0, 256, size=(256, 512, 3), dtype="uint8") out_img = Image.open(image.array_to_png(testdata)).convert("RGBA") out_data = np.asarray(out_img) assert out_da...
out_data[..., :-1])
assert_*
complex_expr
tests/test_image.py
test_array_to_png_rgb
46
null
DHI/terracotta
from io import BytesIO import json import urllib.parse from PIL import Image import marshmallow import numpy as np import pytest def flask_app(): from terracotta.server import create_app return create_app() def client(flask_app): with flask_app.test_client() as client: yield client def debug_f...
200
assert
numeric_literal
tests/server/test_flask_api.py
test_get_keys
46
null
DHI/terracotta
import pytest import platform import time import numpy as np from terracotta import exceptions DRIVERS = ["sqlite", "mysql"] # Some database dialects have issues with float precision METADATA_KEYS = ("bounds", "range", "mean", "stdev", "percentiles", "metadata") def dynamic_non_writable_db(monkeypatch, driver_pat...
data2)
assert_*
variable
tests/drivers/test_raster_drivers.py
test_raster_retrieval
362
null
DHI/terracotta
import pytest from click.testing import CliRunner def test_entrypoint_exception(monkeypatch, capsys): import sys from terracotta.scripts.cli import cli, entrypoint dummy_error_message = "Dummy error message" @cli.command("dummy") def dummy(): raise RuntimeError(dummy_error_message) w...
captured.err
assert
complex_expr
tests/scripts/test_cli.py
test_entrypoint_exception
70
null
DHI/terracotta
import pytest def client_app(test_server): from terracotta.client.flask_api import create_app yield create_app(test_server) def client(client_app, test_server): with client_app.test_client() as client: yield client def test_get_app(client, test_server): rv = client.get("/") assert rv.sta...
rv.data.decode("utf-8")
assert
func_call
tests/client/test_client.py
test_get_app
20
null
DHI/terracotta
import pytest from PIL import Image import numpy as np def test_array_to_png_singleband(): from terracotta import image testdata = np.random.randint(0, 256, size=(256, 512), dtype="uint8") out_img = Image.open(image.array_to_png(testdata)).convert("RGBA") out_data = np.asarray(out_img) assert ou...
out_data[..., 0])
assert_*
complex_expr
tests/test_image.py
test_array_to_png_singleband
17
null
DHI/terracotta
import pytest TESTABLE_DRIVERS = ["sqlite", "mysql", "postgresql"] DRIVER_CLASSES = { "sqlite": "SQLiteMetaStore", "sqlite-remote": "SQLiteRemoteMetaStore", "mysql": "MySQLMetaStore", "postgresql": "PostgreSQLMetaStore", } @pytest.mark.parametrize("provider", TESTABLE_DRIVERS) def test_version_match(d...
db.db_version
assert
complex_expr
tests/drivers/test_drivers.py
test_version_match
216
null
DHI/terracotta
import os import tempfile import time import uuid from pathlib import Path import pytest from terracotta import exceptions boto3 = pytest.importorskip("boto3") moto = pytest.importorskip("moto") def mock_aws_env(monkeypatch): with monkeypatch.context() as m: m.setenv("AWS_DEFAULT_REGION", "us-east-1") ...
ValueError)
pytest.raises
variable
tests/drivers/test_sqlite_remote.py
test_invalid_url
93
null
DHI/terracotta
import pytest from click.testing import CliRunner def toml_file(tmpdir_factory): content = """ DEFAULT_TILE_SIZE = [64, 64] """ outfile = tmpdir_factory.mktemp("config").join("tc-config.toml") with open(outfile, "w") as f: f.write(content) return outfile def test_serve_from_pattern(r...
0
assert
numeric_literal
tests/scripts/test_serve.py
test_serve_from_pattern
25
null
DHI/terracotta
import json import pytest def test_terracotta_settings(): from terracotta import config settings = config.parse_config() assert settings.DEFAULT_TILE_SIZE with pytest.raises(
AttributeError)
pytest.raises
variable
tests/test_config.py
test_terracotta_settings
68
null
DHI/terracotta
import json import pytest def get_client(metadata_origins=None, tile_origins=None): from terracotta.server import create_app import terracotta if metadata_origins is not None: terracotta.update_settings(ALLOWED_ORIGINS_METADATA=metadata_origins) if tile_origins is not None: terracott...
200
assert
numeric_literal
tests/server/test_cors.py
test_cors
43
null
DHI/terracotta
from io import BytesIO import json import urllib.parse from PIL import Image import marshmallow import numpy as np import pytest def flask_app(): from terracotta.server import create_app return create_app() def client(flask_app): with flask_app.test_client() as client: yield client def debug_f...
1
assert
numeric_literal
tests/server/test_flask_api.py
test_get_datasets_pagination
169
null
DHI/terracotta
from PIL import Image import numpy as np import pytest from terracotta import exceptions def test_rgb_tile_size(use_testdb, raster_file, raster_file_xyz): from terracotta.handlers import rgb raw_img = rgb.rgb( ["val21", "x"], ["val22", "val23", "val24"], raster_file_xyz, tile...
(100, 100, 3)
assert
collection
tests/handlers/test_rgb.py
test_rgb_tile_size
28
null
DHI/terracotta
import pytest import numpy as np def reload_cmap(): import importlib import terracotta.cmaps.get_cmaps try: yield finally: importlib.reload(terracotta.cmaps.get_cmaps) def test_extra_cmap_invalid_folder(monkeypatch): import importlib import terracotta.cmaps.get_cmaps wit...
IOError)
pytest.raises
variable
tests/cmaps/test_get_cmap.py
test_extra_cmap_invalid_folder
96
null
DHI/terracotta
import pytest from PIL import Image import numpy as np def test_contrast_stretch(): from terracotta import image data = np.arange(0, 10) np.testing.assert_array_equal(
np.arange(10, 20))
assert_*
func_call
tests/test_image.py
test_contrast_stretch
71
null
DHI/terracotta
import logging def test_logstream(caplog, capsys): from terracotta import logs assert logs.use_colors logger = logs.set_logger("DEBUG") caplog.set_level("DEBUG", logger="terracotta") logger.warning("test") log_out = caplog.records assert len(log_out) ==
1
assert
numeric_literal
tests/test_logs.py
test_logstream
14
null
DHI/terracotta
import pytest import numpy as np import rasterio import rasterio.features from shapely.geometry import shape, MultiPolygon def geometry_mismatch(shape1, shape2): """Compute relative mismatch of two shapes""" return shape1.symmetric_difference(shape2).area / shape1.union(shape2).area def convex_hull_exact(src...
(256, 256)
assert
collection
tests/test_raster.py
test_get_raster_tile
246
null
DHI/terracotta
import pytest from click.testing import CliRunner def test_entrypoint(monkeypatch, capsys): import sys from terracotta.scripts.cli import entrypoint with monkeypatch.context() as m: m.setattr(sys, "argv", ["terracotta"]) with pytest.raises(SystemExit) as exc: entrypoint() ...
captured.out
assert
complex_expr
tests/scripts/test_cli.py
test_entrypoint
50
null
DHI/terracotta
from PIL import Image import numpy as np def test_compute_transparency_nan(use_testdb, testdb, raster_file_xyz): import terracotta from terracotta.xyz import get_tile_data from terracotta.handlers import compute raw_img = compute.compute( "where(v1 > 0, nan, v1 + v2)", ["val21", "x"], ...
np.where(v1.mask | (v1 > 0), 0, 255))
assert_*
func_call
tests/handlers/test_compute.py
test_compute_transparency_nan
69
null
DHI/terracotta
import json import pytest def get_client(metadata_origins=None, tile_origins=None): from terracotta.server import create_app import terracotta if metadata_origins is not None: terracotta.update_settings(ALLOWED_ORIGINS_METADATA=metadata_origins) if tile_origins is not None: terracott...
expected
assert
variable
tests/server/test_cors.py
test_cors
54
null
DHI/terracotta
import pytest TESTABLE_DRIVERS = ["sqlite", "mysql", "postgresql"] DRIVER_CLASSES = { "sqlite": "SQLiteMetaStore", "sqlite-remote": "SQLiteRemoteMetaStore", "mysql": "MySQLMetaStore", "postgresql": "PostgreSQLMetaStore", } @pytest.mark.parametrize("provider", TESTABLE_DRIVERS) def test_use_credentials...
"bar"
assert
string_literal
tests/drivers/test_drivers.py
test_use_credentials_from_settings
289
null
DHI/terracotta
from click.testing import CliRunner def parse_version(verstr): """Convert 'v<major>.<minor>.<patch>' to (major, minor, patch)""" components = verstr.split(".") components[0] = components[0].lstrip("v") return tuple(int(c) for c in components[:3]) def migration_testfunc(v07_db, raster_file): import...
result.output
assert
complex_expr
tests/scripts/test_migrate.py
migration_testfunc
34
null
DHI/terracotta
import os import warnings import traceback import rasterio import numpy as np from click.testing import CliRunner import pytest def format_exception(result): return "".join(traceback.format_exception(*result.exc_info)) def tiny_raster_file(unoptimized_raster_file, tmpdir_factory): tmpdir = tmpdir_factory.m...
2
assert
numeric_literal
tests/scripts/test_optimize_rasters.py
test_reoptimize
211
null
DHI/terracotta
import pytest TESTABLE_DRIVERS = ["sqlite", "mysql", "postgresql"] DRIVER_CLASSES = { "sqlite": "SQLiteMetaStore", "sqlite-remote": "SQLiteRemoteMetaStore", "mysql": "MySQLMetaStore", "postgresql": "PostgreSQLMetaStore", } @pytest.mark.parametrize("provider", TESTABLE_DRIVERS) def test_creation(driver...
{}
assert
collection
tests/drivers/test_drivers.py
test_creation
103
null
DHI/terracotta
import json import pytest def test_env_config(monkeypatch): from terracotta import config with monkeypatch.context() as m: m.setenv("TC_DRIVER_PATH", "test") assert config.parse_config().DRIVER_PATH == "test" with monkeypatch.context() as m: m.setenv("TC_DRIVER_PATH", "test2") ...
(1, 2)
assert
collection
tests/test_config.py
test_env_config
27
null
DHI/terracotta
import pytest import platform import time import numpy as np from terracotta import exceptions DRIVERS = ["sqlite", "mysql"] # Some database dialects have issues with float precision METADATA_KEYS = ("bounds", "range", "mean", "stdev", "percentiles", "metadata") def dynamic_non_writable_db(monkeypatch, driver_pat...
1
assert
numeric_literal
tests/drivers/test_raster_drivers.py
test_pagination
146
null
DHI/terracotta
from PIL import Image import numpy as np import pytest from terracotta import exceptions def test_rgb_out_of_bounds(use_testdb, raster_file): import terracotta from terracotta.handlers import rgb with pytest.raises(
terracotta.exceptions.TileOutOfBoundsError)
pytest.raises
complex_expr
tests/handlers/test_rgb.py
test_rgb_out_of_bounds
64
null
DHI/terracotta
from io import BytesIO import json import urllib.parse from PIL import Image import marshmallow import numpy as np import pytest def flask_app(): from terracotta.server import create_app return create_app() def client(flask_app): with flask_app.test_client() as client: yield client def debug_f...
2
assert
numeric_literal
tests/server/test_flask_api.py
test_post_metadata
101
null
DHI/terracotta
import pytest import numpy as np def reload_cmap(): import importlib import terracotta.cmaps.get_cmaps try: yield finally: importlib.reload(terracotta.cmaps.get_cmaps) def test_extra_cmap_invalid_shape(monkeypatch, tmpdir): import importlib import terracotta.cmaps.get_cmaps ...
ValueError)
pytest.raises
variable
tests/cmaps/test_get_cmap.py
test_extra_cmap_invalid_shape
82
null
DHI/terracotta
import json import pytest def get_client(metadata_origins=None, tile_origins=None): from terracotta.server import create_app import terracotta if metadata_origins is not None: terracotta.update_settings(ALLOWED_ORIGINS_METADATA=metadata_origins) if tile_origins is not None: terracott...
"*"
assert
string_literal
tests/server/test_cors.py
test_cors
49
null
DHI/terracotta
import pytest from click.testing import CliRunner import os import shutil TEST_CASES = ( { # basic "filenames": ["foo.tif"], "input_pattern": "{name}.tif", "expected_keys": ["name"], "expected_datasets": [("foo",)], }, { # two keys "filenames": ["S2_20180101_B04.t...
result.output.lower()
assert
func_call
tests/scripts/test_ingest.py
test_ingest_invalid_pattern
275
null
DHI/terracotta
from click.testing import CliRunner def parse_version(verstr): """Convert 'v<major>.<minor>.<patch>' to (major, minor, patch)""" components = verstr.split(".") components[0] = components[0].lstrip("v") return tuple(int(c) for c in components[:3]) def migration_testfunc(v07_db, raster_file): import...
("key1", "akey", "key2")
assert
collection
tests/scripts/test_migrate.py
migration_testfunc
39
null
DHI/terracotta
def test_datasets_handler(testdb, use_testdb): import terracotta from terracotta.handlers import datasets driver = terracotta.get_driver(str(testdb)) keys = driver.key_names assert datasets.datasets() assert datasets.datasets() ==
[ dict(zip(keys, pair)) for pair in driver.get_datasets().keys() ]
assert
collection
tests/handlers/test_datasets.py
test_datasets_handler
8
null
DHI/terracotta
import pytest def client_app(test_server): from terracotta.client.flask_api import create_app yield create_app(test_server) def client(client_app, test_server): with client_app.test_client() as client: yield client def test_get_app(client, test_server): rv = client.get("/") assert rv.st...
200
assert
numeric_literal
tests/client/test_client.py
test_get_app
19
null
DHI/terracotta
from PIL import Image import numpy as np import pytest from terracotta import exceptions def test_singleband_noxyz(use_testdb): from terracotta import get_settings from terracotta.handlers import singleband settings = get_settings() ds_keys = ["val21", "x", "val22"] raw_img = singleband.singleb...
settings.DEFAULT_TILE_SIZE
assert
complex_expr
tests/handlers/test_singleband.py
test_singleband_noxyz
116
null
DHI/terracotta
import pytest import numpy as np import rasterio import rasterio.features from shapely.geometry import shape, MultiPolygon def geometry_mismatch(shape1, shape2): """Compute relative mismatch of two shapes""" return shape1.symmetric_difference(shape2).area / shape1.union(shape2).area def convex_hull_exact(src...
str(record[0].message)
assert
func_call
tests/test_raster.py
test_compute_metadata
72
null
DHI/terracotta
import os import tempfile import time import uuid from pathlib import Path import pytest from terracotta import exceptions boto3 = pytest.importorskip("boto3") moto = pytest.importorskip("moto") def mock_aws_env(monkeypatch): with monkeypatch.context() as m: m.setenv("AWS_DEFAULT_REGION", "us-east-1") ...
exceptions.InvalidDatabaseError)
pytest.raises
complex_expr
tests/drivers/test_sqlite_remote.py
test_nonexisting_url
101
null