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 |
|---|---|---|---|---|---|---|---|---|---|
MasoniteFramework/masonite | from tests import TestCase
import os
import time
import pytest
class TestMemcacheCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store("memcache")
def test_remember_datatypes(self):
self.driver.rememb... | dict) | self.assertIsInstance | variable | tests/features/cache/test_memcache_cache.py | test_remember_datatypes | TestMemcacheCache | 54 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
import pytest
class TestRedisCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store("redis")
def test_can_increment(self):
self.driver.put("count", "1")... | "1") | self.assertEqual | string_literal | tests/features/cache/test_redis_cache.py | test_can_increment | TestRedisCache | 24 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.validation import email, isnt, is_in, numeric
from src.masonite.validation import Validator
class TestValidation(TestCase):
def test_can_forward_validation_calls(self):
request = self.make_request(query_string="")
validate = Validator()
errors ... | errors.get("email")) | self.assertIn | func_call | tests/features/validation/test_request_validation.py | test_can_forward_validation_calls | TestValidation | 86 | null |
MasoniteFramework/masonite | from tests import TestCase
from masoniteorm.models import Model
from src.masonite.authorization import Authorizes
from src.masonite.facades import Gate
class TestAuthorizes(TestCase):
def setUp(self):
super().setUp()
self.make_request()
def test_user_cannot(self):
user = User.find(1)
... | user.cannot("delete-post")) | self.assertTrue | func_call | tests/core/authorization/test_authorizes.py | test_user_cannot | TestAuthorizes | 27 | null |
MasoniteFramework/masonite | import json
import io
import os
from pprint import pprint
import sys
import pytest
import unittest
import pendulum
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any
from pprint import pprint
from ..cookies import CookieJar
from ..routes import Route
from ..utils.http import generate_wsgi
from... | count) | self.assertEqual | variable | src/masonite/tests/TestCase.py | assertDatabaseCount | TestCase | 447 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | None) | self.assertEqual | none_literal | tests/core/request/test_input.py | test_can_get_defaults | TestInput | 75 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
import pytest
class TestMemcacheCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store("memcache")
def test_can_increment(self):
self.driver.put("count"... | "1") | self.assertEqual | string_literal | tests/features/cache/test_memcache_cache.py | test_can_increment | TestMemcacheCache | 24 | null |
MasoniteFramework/masonite | from tests import TestCase
from masoniteorm.models import Model
from src.masonite.exceptions.exceptions import AuthorizationException, GateDoesNotExist
from src.masonite.authorization import AuthorizationResponse
from src.masonite.routes import Route
class TestGate(TestCase):
def setUp(self):
super().setU... | response.allowed()) | self.assertFalse | func_call | tests/core/authorization/test_gate.py | test_inspect | TestGate | 126 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.facades import Dump
from src.masonite.exceptions import DumpException
class TestDumper(TestCase):
def setUp(self):
super().setUp()
self.dumper = self.application.make("dumper")
def tearDown(self):
super().tearDown()
self.dumper.clea... | 1 | assert | numeric_literal | tests/features/dumps/test_dumper.py | test_dump | TestDumper | 27 | null |
MasoniteFramework/masonite | import sys
from tests import TestCase
from src.masonite.rates import UnlimitedLimiter, GlobalLimiter, Limit, GuestsOnlyLimiter
from tests.integrations.app.User import User
class TestLimiters(TestCase):
def test_global(self):
request = "fake"
limiter = GlobalLimiter("3/minute")
limit = lim... | 24 * 60 | assert | complex_expr | tests/features/rates/test_limits.py | test_global | TestLimiters | 59 | null |
MasoniteFramework/masonite | from unittest import TestCase
from src.masonite.routes import Route
from tests.integrations.controllers.WelcomeController import WelcomeController
class TestParsingControllerInRoutes(TestCase):
def setUp(self):
Route.set_controller_locations("tests.integrations.controllers")
pass
def test_use... | "test" | assert | string_literal | tests/routes/test_parsing_controllers.py | test_use_controller_string_with_method | TestParsingControllerInRoutes | 23 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.utils.str import (
random_string,
removeprefix,
removesuffix,
get_controller_name,
add_query_params,
)
from tests.integrations.controllers.api.TestController import TestController
class TestStringsUtils(TestCase):
def test_random_string(self):
... | str) | self.assertIsInstance | variable | tests/core/utils/test_str.py | test_random_string | TestStringsUtils | 18 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
class TestFileCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store()
def test_remember_datatypes(self):
self.driver.remember(
"dic", lambd... | dict) | self.assertIsInstance | variable | tests/features/cache/test_file_cache.py | test_remember_datatypes | TestFileCache | 52 | null |
MasoniteFramework/masonite | from tests import TestCase
class TestCookieSession(TestCase):
def test_can_increment_and_decrement_session(self):
self.make_request()
session = self.application.make("session")
session.start("cookie")
session.set("key1", "1")
session.set("key5", "5")
session.increme... | "4") | self.assertEqual | string_literal | tests/features/session/test_cookie_session.py | test_can_increment_and_decrement_session | TestCookieSession | 43 | null |
MasoniteFramework/masonite | import time
import pytest
from src.masonite.events import Event
from tests import TestCase
class TestEvent(TestCase):
def setUp(self):
super().setUp()
self.event = self.application.make("event")
self.event.listen(UserAddedEvent, [SendEmailListener])
def tearDown(self):
super(... | ["user.added"]) | self.assertEqual | collection | tests/features/event/test_event.py | test_fire_event_string | TestEvent | 84 | null |
MasoniteFramework/masonite | import sys
from tests import TestCase
from src.masonite.rates import UnlimitedLimiter, GlobalLimiter, Limit, GuestsOnlyLimiter
from tests.integrations.app.User import User
class TestLimits(TestCase):
def test_limit_unlimited(self):
limit = Limit.unlimited()
assert limit.max_attempts == | sys.maxsize | assert | complex_expr | tests/features/rates/test_limits.py | test_limit_unlimited | TestLimits | 36 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.utils.str import (
random_string,
removeprefix,
removesuffix,
get_controller_name,
add_query_params,
)
from tests.integrations.controllers.api.TestController import TestController
class TestStringsUtils(TestCase):
def test_random_string(self):
... | random_string()) | self.assertNotEqual | func_call | tests/core/utils/test_str.py | test_random_string | TestStringsUtils | 19 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.notification import SlackMessage
class TestSlackMessage(TestCase):
def test_from_options(self):
slack_message = SlackMessage().from_("sam", icon=":ghost").build().get_options()
self.assertEqual(slack_message.get("username"), "sam")
self.assertEq... | "") | self.assertEqual | string_literal | tests/features/notification/test_slack_message.py | test_from_options | TestSlackMessage | 37 | null |
MasoniteFramework/masonite | import unittest
from src.masonite.validation import MessageBag
class TestMessageBag(unittest.TestCase):
def setUp(self):
self.bag = MessageBag()
def test_has_message(self):
self.bag.reset()
self.assertFalse( | self.bag.has("email")) | self.assertFalse | func_call | tests/features/validation/test_messagebag.py | test_has_message | TestMessageBag | 50 | null |
MasoniteFramework/masonite | import time
import pytest
from src.masonite.events import Event
from tests import TestCase
class TestEvent(TestCase):
def setUp(self):
super().setUp()
self.event = self.application.make("event")
self.event.listen(UserAddedEvent, [SendEmailListener])
def tearDown(self):
super(... | []) | self.assertEqual | collection | tests/features/event/test_event.py | test_fire_event_string | TestEvent | 77 | null |
MasoniteFramework/masonite | from unittest.mock import MagicMock
from src.masonite.middleware import MiddlewareCapsule
from tests import TestCase
class TestMiddleware(TestCase):
def test_can_create_capsule(self):
capsule = MiddlewareCapsule()
self.assertTrue( | capsule) | self.assertTrue | variable | tests/core/middleware/test_middleware.py | test_can_create_capsule | TestMiddleware | 19 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | "me") | self.assertEqual | string_literal | tests/core/request/test_input.py | test_can_parse_query_string | TestInput | 42 | null |
MasoniteFramework/masonite | import time
import pytest
from src.masonite.events import Event
from tests import TestCase
class TestEvent(TestCase):
def setUp(self):
super().setUp()
self.event = self.application.make("event")
self.event.listen(UserAddedEvent, [SendEmailListener])
def tearDown(self):
super(... | ["view.*"]) | self.assertEqual | collection | tests/features/event/test_event.py | test_fire_event_string | TestEvent | 83 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
class TestFileCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store()
def test_can_increment(self):
self.driver.put("count", "1")
self.assertE... | "1") | self.assertEqual | string_literal | tests/features/cache/test_file_cache.py | test_can_increment | TestFileCache | 22 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.facades import Dump
from src.masonite.exceptions import DumpException
class TestDumper(TestCase):
def setUp(self):
super().setUp()
self.dumper = self.application.make("dumper")
def tearDown(self):
super().tearDown()
self.dumper.clea... | "value" | assert | string_literal | tests/features/dumps/test_dumper.py | test_serialize_dump_properties | TestDumper | 66 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.helpers import optional
class TestOptionalHelper(TestCase):
def test_optional_with_default(self):
obj = SomeClass()
assert optional(obj, 0).non_existing_attr == | 0 | assert | numeric_literal | tests/core/helpers/test_optional.py | test_optional_with_default | TestOptionalHelper | 33 | null |
MasoniteFramework/masonite | from tests import TestCase
from masoniteorm.models import Model
from tests.integrations.policies.PostPolicy import PostPolicy
from src.masonite.exceptions.exceptions import PolicyDoesNotExist
class TestPolicies(TestCase):
def setUp(self):
super().setUp()
self.gate = self.application.make("gate")
... | response.allowed()) | self.assertFalse | func_call | tests/core/authorization/test_policies.py | test_using_policy_returning_response | TestPolicies | 55 | null |
MasoniteFramework/masonite | from tests import TestCase
class TestCookieSession(TestCase):
def test_can_increment_and_decrement_session(self):
self.make_request()
session = self.application.make("session")
session.start("cookie")
session.set("key1", "1")
session.set("key5", "5")
session.increme... | "2") | self.assertEqual | string_literal | tests/features/session/test_cookie_session.py | test_can_increment_and_decrement_session | TestCookieSession | 42 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.notification import Sms
class TestSms(TestCase):
def test_adding_client_ref(self):
sms = Welcome().client_ref("ABCD").build().get_options()
self.assertEqual(sms.get("client-ref"), | "ABCD") | self.assertEqual | string_literal | tests/features/notification/test_sms.py | test_adding_client_ref | TestSms | 24 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.loader.Loader import Loader
from src.masonite.exceptions import LoaderNotFound
OBJ_1 = "test"
class TestLoader(TestCase):
def setUp(self):
super().setUp()
self.loader = Loader()
def test_get_objects(self):
objects = self.loader.get_objects... | "test") | self.assertEqual | string_literal | tests/features/loader/test_loader.py | test_get_objects | TestLoader | 17 | null |
MasoniteFramework/masonite | import json
from ..views import View
from ..controllers import Controller
from ..utils.structures import data_get
class HttpTestResponse:
def __init__(self, testcase, application, request, response, route):
self.testcase = testcase
self.application = application
self.request = request
... | self.get_content() | assert | func_call | src/masonite/tests/HttpTestResponse.py | assertContains | HttpTestResponse | 32 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.utils.structures import data_get, data_set, data
class TestStructures(TestCase):
def test_data_set(self):
struct = {"key": "val", "a": {"b": "c", "nested": {"a": 1}}}
data_set(struct, "key", "val2")
self.assertEqual(struct.get("key"), | "val2") | self.assertEqual | string_literal | tests/core/utils/test_structures.py | test_data_set | TestStructures | 20 | null |
MasoniteFramework/masonite | import unittest
from src.masonite.validation import MessageBag
class TestMessageBag(unittest.TestCase):
def setUp(self):
self.bag = MessageBag()
def test_message_bag_has_any_errors(self):
self.bag.reset()
self.assertFalse( | self.bag.any()) | self.assertFalse | func_call | tests/features/validation/test_messagebag.py | test_message_bag_has_any_errors | TestMessageBag | 24 | null |
MasoniteFramework/masonite | from typing import TYPE_CHECKING
from tests import TestCase
from tests.integrations.app.SayHi import SayHello
from tests.integrations.app.GreetingService import GreetingService
from tests.integrations.app.User import User
from src.masonite.exceptions import (
StrictContainerException,
MissingContainerBindingNo... | result.name) | self.assertEqual | complex_expr | tests/core/foundation/test_container.py | test_container_can_resolve_nested_class_dependencies_without_binding | TestContainer | 105 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.validation import email, isnt, is_in, numeric
from src.masonite.validation import Validator
class TestValidation(TestCase):
def test_can_forward_validation_calls(self):
request = self.make_request(query_string="")
validate = Validator()
errors ... | errors.get("terms")) | self.assertIn | func_call | tests/features/validation/test_request_validation.py | test_can_forward_validation_calls | TestValidation | 87 | null |
MasoniteFramework/masonite | import json
from ..views import View
from ..controllers import Controller
from ..utils.structures import data_get
class HttpTestResponse:
def __init__(self, testcase, application, request, response, route):
self.testcase = testcase
self.application = application
self.request = request
... | None | assert | none_literal | src/masonite/tests/HttpTestResponse.py | assertIsNotNamed | HttpTestResponse | 58 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | {"hello": "you"}) | self.assertEqual | collection | tests/core/request/test_input.py | test_all_with_values | TestInput | 69 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.foundation import Application
import os
class TestAppApplication(TestCase):
def test_initialize_application(self):
app = Application(os.getcwd())
self.assertTrue( | app) | self.assertTrue | variable | tests/core/foundation/test_app_application.py | test_initialize_application | TestAppApplication | 9 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
from src.masonite.filesystem import File
import pytest
class TestLocalStorage(TestCase):
def setUp(self):
super().setUp()
self.application.make("storage")
self.driver = self.application.make("storage").disk("s3")
def test_can_stream(self... | ".log") | self.assertEqual | string_literal | tests/features/storage/test_s3_storage.py | test_can_stream | TestLocalStorage | 28 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
import pytest
class TestMemcacheCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store("memcache")
def test_remember_datatypes(self):
self.driver.rememb... | list) | self.assertIsInstance | variable | tests/features/cache/test_memcache_cache.py | test_remember_datatypes | TestMemcacheCache | 56 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.middleware import EncryptCookies
class TestEncryptCookiesMiddleware(TestCase):
def test_encrypts_cookies(self):
request = self.make_request(
{"HTTP_COOKIE": f"test={self.application.make('sign').sign('value')}"}
)
response = self.mak... | "value") | self.assertEqual | string_literal | tests/core/middleware/test_encrypt_cookies.py | test_encrypts_cookies | TestEncryptCookiesMiddleware | 13 | null |
MasoniteFramework/masonite | from typing import TYPE_CHECKING
from tests import TestCase
from tests.integrations.app.SayHi import SayHello
from tests.integrations.app.GreetingService import GreetingService
from tests.integrations.app.User import User
from src.masonite.exceptions import (
StrictContainerException,
MissingContainerBindingNo... | "test") | self.assertEqual | string_literal | tests/core/foundation/test_container.py | test_can_bind_object | TestContainer | 55 | null |
MasoniteFramework/masonite | from unittest.mock import MagicMock
from src.masonite.middleware import MiddlewareCapsule
from tests import TestCase
class TestMiddleware(TestCase):
def test_can_mix_args_and_request_inputs(self):
# this create a request with @user_id as in input
request = self.make_request(query_string="user_id=... | "value") | assert_* | string_literal | tests/core/middleware/test_middleware.py | test_can_mix_args_and_request_inputs | TestMiddleware | 100 | null |
MasoniteFramework/masonite | import sys
from tests import TestCase
from src.masonite.rates import UnlimitedLimiter, GlobalLimiter, Limit, GuestsOnlyLimiter
from tests.integrations.app.User import User
class TestLimits(TestCase):
def test_limit_per_day(self):
limit = Limit.per_day(10)
assert limit.max_attempts == 10
... | 60 * 24 | assert | complex_expr | tests/features/rates/test_limits.py | test_limit_per_day | TestLimits | 27 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
class TestFileCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store()
def test_will_not_get_expired(self):
self.driver.put("expire", "1", 1)
t... | None) | self.assertEqual | none_literal | tests/features/cache/test_file_cache.py | test_will_not_get_expired | TestFileCache | 32 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.facades import Dump
from src.masonite.exceptions import DumpException
class TestDumper(TestCase):
def setUp(self):
super().setUp()
self.dumper = self.application.make("dumper")
def tearDown(self):
super().tearDown()
self.dumper.clea... | "a" | assert | string_literal | tests/features/dumps/test_dumper.py | test_dump_can_get_variables_name | TestDumper | 43 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.notification import SlackMessage
class TestSlackMessage(TestCase):
def test_build_message(self):
slack_message = WelcomeToSlack().build().get_options()
self.assertEqual(slack_message.get("channel"), "#general")
self.assertEqual(slack_message.get(... | "[]") | self.assertEqual | string_literal | tests/features/notification/test_slack_message.py | test_build_message | TestSlackMessage | 31 | null |
MasoniteFramework/masonite | from typing import TYPE_CHECKING
from tests import TestCase
from tests.integrations.app.SayHi import SayHello
from tests.integrations.app.GreetingService import GreetingService
from tests.integrations.app.User import User
from src.masonite.exceptions import (
StrictContainerException,
MissingContainerBindingNo... | 0) | self.assertGreater | numeric_literal | tests/core/foundation/test_container.py | test_can_collect_bindings | TestContainer | 113 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.facades import Hash
class TestHashers(TestCase):
def test_should_return_hash_content_as_bytes(self):
for driver in Hash.drivers.keys():
hashed = Hash.make_bytes("masonite", driver=driver)
assert type(hashed) == | bytes | assert | variable | tests/features/hashing/test_hashers.py | test_should_return_hash_content_as_bytes | TestHashers | 42 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.validation import email, isnt, is_in, numeric
from src.masonite.validation import Validator
class TestValidation(TestCase):
def test_custom_messages(self):
request = self.make_request(post_data={"not_email": "joe@masonite.com", "age": 20})
# validator =... | validate.get("not_email")) | self.assertIn | func_call | tests/features/validation/test_request_validation.py | test_custom_messages | TestValidation | 59 | null |
MasoniteFramework/masonite | from cleo import CommandTester
from typing import TYPE_CHECKING
class TestCommand:
def __init__(self, application: "Application"):
self.application = application
def run(self, command: str, arguments_str: str = "") -> "TestCommand":
"""Run the given craft command. Commands arguments should be... | output | assert | variable | src/masonite/tests/TestCommand.py | assertExactOutput | TestCommand | 25 | null |
MasoniteFramework/masonite | from src.masonite.configuration import config
from src.masonite.helpers import url, optional
from src.masonite.sessions import old
from tests import TestCase
from jinja2 import TemplateNotFound
class TestView(TestCase):
def setUp(self):
super().setUp()
# keep this to have a "fresh view instance" fo... | "test") | self.assertEqual | string_literal | tests/core/views/test_view.py | test_view_gets_global_template | TestView | 53 | null |
MasoniteFramework/masonite | from tests import TestCase
from masoniteorm.models import Model
from src.masonite.exceptions.exceptions import AuthorizationException, GateDoesNotExist
from src.masonite.authorization import AuthorizationResponse
from src.masonite.routes import Route
class TestGate(TestCase):
def setUp(self):
super().setU... | Gate.define) | self.assertEqual | complex_expr | tests/core/authorization/test_gate.py | test_can_use_gate_facade | TestGate | 61 | null |
MasoniteFramework/masonite | from src.masonite.utils.http import HTTP_STATUS_CODES
from tests import TestCase
from src.masonite.exceptions.exceptions import MethodNotAllowedException
from src.masonite.routes import Route, Router
class TestRoutes(TestCase):
def setUp(self):
super().setUp()
Route.set_controller_locations("tests... | "2") | self.assertEqual | string_literal | tests/routes/test_routes.py | test_extract_parameters | TestRoutes | 166 | null |
MasoniteFramework/masonite | from typing import TYPE_CHECKING
from tests import TestCase
from tests.integrations.app.SayHi import SayHello
from tests.integrations.app.GreetingService import GreetingService
from tests.integrations.app.User import User
from src.masonite.exceptions import (
StrictContainerException,
MissingContainerBindingNo... | 1) | self.assertEqual | numeric_literal | tests/core/foundation/test_container.py | test_can_bind_object | TestContainer | 54 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.utils.http import generate_wsgi
from src.masonite.request import Request
class TestRequest(TestCase):
def setUp(self):
super().setUp()
self.request = Request(generate_wsgi(path="/test"))
def test_request_no_input_returns_empty_string(self):
... | "") | self.assertEqual | string_literal | tests/core/request/test_request_input.py | test_request_no_input_returns_empty_string | TestRequest | 13 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.mail import Mailable
from src.masonite.mail.Recipient import Recipient
class TestMailable(TestCase):
def setUp(self):
super().setUp()
self.application.make("mail")
def test_build_mail(self):
mailable = Welcome().build().get_options()
... | "") | self.assertEqual | string_literal | tests/features/mail/test_mailable.py | test_build_mail | TestMailable | 39 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
import pytest
class TestRedisCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store("redis")
def test_flush(self):
self.driver.remember(
"di... | self.driver.get("dic")) | self.assertIsNone | func_call | tests/features/cache/test_redis_cache.py | test_flush | TestRedisCache | 67 | null |
MasoniteFramework/masonite | import unittest
from src.masonite.cookies import CookieJar
from src.masonite.utils.time import cookie_expire_time
class TestCookies(unittest.TestCase):
def test_cookie_can_load(self):
cookiejar = CookieJar()
cookiejar.add("cookie1", "name", http_only=False)
cookiejar.load("csrf_token=tok"... | "tok") | self.assertEqual | string_literal | tests/core/cookies/test_cookies.py | test_cookie_can_load | TestCookies | 83 | null |
MasoniteFramework/masonite | import json
from ..views import View
from ..controllers import Controller
from ..utils.structures import data_get
class HttpTestResponse:
def __init__(self, testcase, application, request, response, route):
self.testcase = testcase
self.application = application
self.request = request
... | data | assert | variable | src/masonite/tests/HttpTestResponse.py | assertJsonExact | HttpTestResponse | 351 | null |
MasoniteFramework/masonite | from src.masonite.utils.http import HTTP_STATUS_CODES
from tests import TestCase
from src.masonite.exceptions.exceptions import MethodNotAllowedException
from src.masonite.routes import Route, Router
class TestRoutes(TestCase):
def setUp(self):
super().setUp()
Route.set_controller_locations("tests... | route) | self.assertTrue | variable | tests/routes/test_routes.py | test_can_find_route | TestRoutes | 28 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.helpers import optional
class TestOptionalHelper(TestCase):
def test_optional_with_undefined(self):
obj = SomeClass()
assert optional(obj).non_existing_attr is | None | assert | none_literal | tests/core/helpers/test_optional.py | test_optional_with_undefined | TestOptionalHelper | 22 | null |
MasoniteFramework/masonite | import unittest
from src.masonite.validation import MessageBag
class TestMessageBag(unittest.TestCase):
def setUp(self):
self.bag = MessageBag()
def test_get_messages_with_same_keys(self):
self.bag.reset()
self.bag.add("email", "Your email is invalid")
self.bag.add("email", "Yo... | self.bag.get("email")) | self.assertIn | func_call | tests/features/validation/test_messagebag.py | test_get_messages_with_same_keys | TestMessageBag | 61 | null |
MasoniteFramework/masonite | import unittest
from src.masonite.validation import MessageBag
class TestMessageBag(unittest.TestCase):
def setUp(self):
self.bag = MessageBag()
def test_has_message(self):
self.bag.reset()
self.assertFalse(self.bag.has("email"))
self.assertFalse( | self.bag.has("username")) | self.assertFalse | func_call | tests/features/validation/test_messagebag.py | test_has_message | TestMessageBag | 51 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.utils.str import (
random_string,
removeprefix,
removesuffix,
get_controller_name,
add_query_params,
)
from tests.integrations.controllers.api.TestController import TestController
class TestStringsUtils(TestCase):
def test_removeprefix(self):
... | "Event") | self.assertEqual | string_literal | tests/core/utils/test_str.py | test_removeprefix | TestStringsUtils | 26 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.utils.filesystem import get_extension
class TestFileUtils(TestCase):
def test_get_extension(self):
self.assertEqual(get_extension("log.txt"), ".txt")
self.assertEqual(get_extension("archive.tar.gz"), ".tar.gz")
self.assertEqual(get_extension("pa... | "txt") | self.assertEqual | string_literal | tests/core/utils/test_filesystem.py | test_get_extension | TestFileUtils | 16 | null |
MasoniteFramework/masonite | from tests import TestCase
import os
import time
class TestFileCache(TestCase):
def setUp(self):
super().setUp()
self.application.make("cache")
self.driver = self.application.make("cache").store()
def test_remember_datatypes(self):
self.driver.remember(
"dic", lambd... | list) | self.assertIsInstance | variable | tests/features/cache/test_file_cache.py | test_remember_datatypes | TestFileCache | 54 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.notification import Notification, Notifiable
from src.masonite.mail import Mailable
from masoniteorm.models import Model
class TestNotification(TestCase):
def test_should_send(self):
notification = WelcomeNotification()
self.assertTrue( | notification.should_send()) | self.assertTrue | func_call | tests/features/notification/test_notification.py | test_should_send | TestNotification | 30 | null |
MasoniteFramework/masonite | import pendulum
import os
import pytest
import sys
from tests import TestCase
from tests.integrations.controllers.WelcomeController import WelcomeController
from masoniteorm.models import Model
from src.masonite.routes import Route
from src.masonite.authentication import Authenticates
from src.masonite.middleware impo... | "value" | assert | string_literal | tests/tests/test_testcase.py | test_with_headers | TestTestingAssertions | 201 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.helpers import optional
class TestOptionalHelper(TestCase):
def test_optional_with_callable_default(self):
obj = SomeClass()
assert optional(obj, lambda the_obj: "a").non_existing_attr == | "a" | assert | string_literal | tests/core/helpers/test_optional.py | test_optional_with_callable_default | TestOptionalHelper | 37 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.utils.filesystem import get_extension
class TestFileUtils(TestCase):
def test_get_extension(self):
self.assertEqual(get_extension("log.txt"), ".txt")
self.assertEqual(get_extension("archive.tar.gz"), ".tar.gz")
self.assertEqual(get_extension("pa... | "") | self.assertEqual | string_literal | tests/core/utils/test_filesystem.py | test_get_extension | TestFileUtils | 13 | null |
MasoniteFramework/masonite | import sys
from tests import TestCase
from src.masonite.rates import UnlimitedLimiter, GlobalLimiter, Limit, GuestsOnlyLimiter
from tests.integrations.app.User import User
class TestLimiters(TestCase):
def test_guests_only(self):
# request as guest
request = self.make_request()
request._i... | 2 | assert | numeric_literal | tests/features/rates/test_limits.py | test_guests_only | TestLimiters | 69 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.routes import Route, HTTPRoute
from src.masonite.exceptions.exceptions import RouteNotFoundException
class TestHttpRequests(TestCase):
def setUp(self):
super().setUp()
self.addRoutes(
Route.get("/test/users/@id", "WelcomeController@show_user"... | "Sam" | assert | string_literal | tests/core/request/test_http_requests.py | test_old_helper | TestHttpRequests | 49 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | "hey") | self.assertEqual | string_literal | tests/core/request/test_input.py | test_can_parse_text_plain_content_type | TestInput | 112 | null |
MasoniteFramework/masonite | import pendulum
from tests import TestCase
from src.masonite.facades import RateLimiter, Cache
def my_function():
return "done"
class TestRateLimiter(TestCase):
def tearDown(self):
super().tearDown()
# delete cache entries between tests for idempotent tests
self.application.make("cach... | "done") | self.assertEqual | string_literal | tests/features/rates/test_rate_limiter.py | test_attempt | TestRateLimiter | 20 | null |
MasoniteFramework/masonite | from src.masonite.essentials.middleware import HashIDMiddleware
from src.masonite.essentials.helpers.hashid import hashid
from tests import TestCase
class TestHashID(TestCase):
def test_hashid_decodes_several_integers(self):
assert hashid("B1I1uo", decode=True) == | (10, 20, 30) | assert | collection | tests/features/hashid/test_hashid_middleware.py | test_hashid_decodes_several_integers | TestHashID | 14 | null |
MasoniteFramework/masonite | import pendulum
import os
import pytest
import sys
from tests import TestCase
from tests.integrations.controllers.WelcomeController import WelcomeController
from masoniteorm.models import Model
from src.masonite.routes import Route
from src.masonite.authentication import Authenticates
from src.masonite.middleware impo... | initial | assert | variable | tests/tests/test_testcase.py | test_env_context_manager | TestTestCase | 92 | null |
MasoniteFramework/masonite | import pendulum
from tests import TestCase
from src.masonite.facades import RateLimiter, Cache
def my_function():
return "done"
class TestRateLimiter(TestCase):
def tearDown(self):
super().tearDown()
# delete cache entries between tests for idempotent tests
self.application.make("cach... | 1 | assert | numeric_literal | tests/features/rates/test_rate_limiter.py | test_remaining | TestRateLimiter | 45 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | ["user1", "user2"]) | self.assertEqual | collection | tests/core/request/test_input.py | test_only_array_based_inputs | TestInput | 101 | null |
MasoniteFramework/masonite | import unittest
from src.masonite.cookies import CookieJar
from src.masonite.utils.time import cookie_expire_time
class TestCookies(unittest.TestCase):
def test_cookies_can_put_to_dict(self):
cookiejar = CookieJar()
cookiejar.add("cookie", "name")
self.assertEqual(cookiejar.to_dict(), | {"cookie": "name"}) | self.assertEqual | collection | tests/core/cookies/test_cookies.py | test_cookies_can_put_to_dict | TestCookies | 17 | null |
MasoniteFramework/masonite | from tests import TestCase
import time
import pytest
class TestRedisSession(TestCase):
def setUp(self):
super().setUp()
self.session = self.application.make("session")
self.driver = self.session.driver("redis")
self.session.start("redis")
def teardown(self):
self.sessio... | self.session.get("dic")) | self.assertIsNone | func_call | tests/features/session/test_redis_session.py | test_flush | TestRedisSession | 53 | null |
MasoniteFramework/masonite | import pendulum
from masoniteorm.models import Model
from tests import TestCase
from src.masonite.tests import DatabaseTransactions
from src.masonite.notification import Notification, Notifiable
from src.masonite.notification import DatabaseNotification
class TestDatabaseDriver(TestCase, DatabaseTransactions):
c... | 1 | assert | numeric_literal | tests/features/notification/test_database_driver.py | test_notify_multiple_users | TestDatabaseDriver | 61 | null |
MasoniteFramework/masonite | from tests import TestCase
class TestCookieSession(TestCase):
def test_can_get_session_dict(self):
request = self.make_request()
session = self.application.make("session")
request.cookie("s_hello", '{"hello": "test"}')
session.start("cookie")
self.assertEqual(type(session.... | dict) | self.assertEqual | variable | tests/features/session/test_cookie_session.py | test_can_get_session_dict | TestCookieSession | 17 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.validation import email, isnt, is_in, numeric
from src.masonite.validation import Validator
class TestValidation(TestCase):
def test_custom_messages(self):
request = self.make_request(post_data={"not_email": "joe@masonite.com", "age": 20})
# validator =... | validate.get("username")) | self.assertIn | func_call | tests/features/validation/test_request_validation.py | test_custom_messages | TestValidation | 63 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.facades import Config
from src.masonite.configuration import config
from src.masonite.exceptions import InvalidConfigurationSetup
PACKAGE_PARAM = 1
OTHER_PARAM = 3
class TestConfiguration(TestCase):
def test_can_merge_external_config_using_path(self):
# reset ... | 3) | self.assertEqual | numeric_literal | tests/core/configuration/test_config.py | test_can_merge_external_config_using_path | TestConfiguration | 68 | null |
MasoniteFramework/masonite | import pendulum
from masoniteorm.models import Model
from tests import TestCase
from src.masonite.tests import DatabaseTransactions
from src.masonite.notification import Notification, Notifiable
from src.masonite.notification import DatabaseNotification
class TestDatabaseDriver(TestCase, DatabaseTransactions):
c... | "users" | assert | string_literal | tests/features/notification/test_database_driver.py | test_database_notification_is_created_correctly | TestDatabaseDriver | 55 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.facades import Dump
from src.masonite.exceptions import DumpException
class TestDumper(TestCase):
def setUp(self):
super().setUp()
self.dumper = self.application.make("dumper")
def tearDown(self):
super().tearDown()
self.dumper.clea... | [] | assert | collection | tests/features/dumps/test_dumper.py | test_get_dumps | TestDumper | 18 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | "you") | self.assertEqual | string_literal | tests/core/request/test_input.py | test_can_parse_query_string | TestInput | 41 | null |
MasoniteFramework/masonite | import json
import io
import os
from pprint import pprint
import sys
import pytest
import unittest
import pendulum
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any
from pprint import pprint
from ..cookies import CookieJar
from ..routes import Route
from ..utils.http import generate_wsgi
from... | 1) | self.assertGreaterEqual | numeric_literal | src/masonite/tests/TestCase.py | assertDatabaseHas | TestCase | 450 | null |
MasoniteFramework/masonite | from src.masonite.configuration import config
from src.masonite.helpers import url, optional
from src.masonite.sessions import old
from tests import TestCase
from jinja2 import TemplateNotFound
class TestView(TestCase):
def setUp(self):
super().setUp()
# keep this to have a "fresh view instance" fo... | content) | self.assertIn | variable | tests/core/views/test_view.py | test_can_access_shared_helpers | TestView | 133 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.loader.Loader import Loader
from src.masonite.exceptions import LoaderNotFound
OBJ_1 = "test"
class TestLoader(TestCase):
def setUp(self):
super().setUp()
self.loader = Loader()
def test_get_objects(self):
objects = self.loader.get_objects... | dict) | self.assertIsInstance | variable | tests/features/loader/test_loader.py | test_get_objects | TestLoader | 16 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | []) | self.assertEqual | collection | tests/core/request/test_input.py | test_can_get_defaults | TestInput | 78 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | "val") | self.assertEqual | string_literal | tests/core/request/test_input.py | test_can_parse_nested_post_data | TestInput | 170 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.response import Response
from src.masonite.routes import Route
class TestResponseRedirect(TestCase):
def setUp(self):
super().setUp()
self.addRoutes(Route.get("/", None).name("home-redirect"))
self.response = Response(self.application)
def t... | "/") | self.assertEqual | string_literal | tests/core/response/test_response_redirections.py | test_redirect | TestResponseRedirect | 15 | null |
MasoniteFramework/masonite | import json
import io
import os
from pprint import pprint
import sys
import pytest
import unittest
import pendulum
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any
from pprint import pprint
from ..cookies import CookieJar
from ..routes import Route
from ..utils.http import generate_wsgi
from... | 0) | self.assertEqual | numeric_literal | src/masonite/tests/TestCase.py | assertDatabaseMissing | TestCase | 455 | null |
MasoniteFramework/masonite | from tests import TestCase
from src.masonite.notification import Sms
class TestSms(TestCase):
def test_build_sms(self):
sms = Welcome().build().get_options()
self.assertEqual(sms.get("to"), "+33612345678")
self.assertEqual(sms.get("from"), "+44123456789")
self.assertEqual(sms.get("t... | "text") | self.assertEqual | string_literal | tests/features/notification/test_sms.py | test_build_sms | TestSms | 16 | null |
MasoniteFramework/masonite | import pendulum
from src.masonite.tests import TestCase
from src.masonite.scheduling import Task
class TestScheduler(TestCase):
def setUp(self):
super().setUp()
self.task = MockTask()
def test_scheduler_should_run(self):
assert self.task.run_every == "5 minutes"
time = pendulum... | True | assert | bool_literal | tests/features/scheduling/test_scheduling.py | test_scheduler_should_run | TestScheduler | 20 | null |
MasoniteFramework/masonite | import binascii
import os
import json
import io
from src.masonite.input import InputBag
from src.masonite.tests import MockInput
from tests import TestCase
def encode_multipart_formdata(fields):
boundary = binascii.hexlify(os.urandom(16)).decode("ascii")
body = (
"".join(
"--%s\r\n"
... | 1) | self.assertEqual | numeric_literal | tests/core/request/test_input.py | test_can_parse_post_data | TestInput | 52 | null |
MasoniteFramework/masonite | from tests import TestCase
import time
import pytest
class TestRedisSession(TestCase):
def setUp(self):
super().setUp()
self.session = self.application.make("session")
self.driver = self.session.driver("redis")
self.session.start("redis")
def teardown(self):
self.sessio... | "test") | self.assertEqual | string_literal | tests/features/session/test_redis_session.py | test_can_flash | TestRedisSession | 39 | null |
MasoniteFramework/masonite | from tests import TestCase
import time
import pytest
class TestRedisSession(TestCase):
def setUp(self):
super().setUp()
self.session = self.application.make("session")
self.driver = self.session.driver("redis")
self.session.start("redis")
def teardown(self):
self.sessio... | "1") | self.assertEqual | string_literal | tests/features/session/test_redis_session.py | test_can_increment | TestRedisSession | 21 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.