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
piccolo-orm/piccolo
from unittest import TestCase from unittest.mock import patch from piccolo.columns import Varchar from piccolo.table import TABLENAME_WARNING, create_table_class class TestCreateTableClass(TestCase): def test_create_table_class(self): """ Make sure a basic `Table` can be created successfully. ...
"my_table")
self.assertEqual
string_literal
tests/table/test_create_table_class.py
test_create_table_class
TestCreateTableClass
14
null
piccolo-orm/piccolo
from piccolo.columns.column_types import JSON from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestJSONSave(TableTest): tables = [MyTable] def test_json_string(self): """ Test storing a valid JSON string. """ row = MyTable(json='{"a": 1}') ...
'{"a":1}')
self.assertEqual
string_literal
tests/columns/test_json.py
test_json_string
TestJSONSave
35
null
piccolo-orm/piccolo
import uuid from piccolo.columns.column_types import ( UUID, BigSerial, ForeignKey, Serial, Varchar, ) from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestPrimaryKeyDefault(TableTest): tables = [MyTableDefaultPrimaryKey] def test_return_type(self): ...
int)
self.assertIsInstance
variable
tests/columns/test_primary_key.py
test_return_type
TestPrimaryKeyDefault
41
null
piccolo-orm/piccolo
import time from unittest import TestCase from piccolo.columns import Column, ForeignKey, LazyTableReference, Varchar from piccolo.table import Table class TestAttributeAccess(TestCase): def test_recursion_limit(self) -> None: """ When a table has a ForeignKey to itself, an Exception should be ra...
len(column._meta.call_chain))
self.assertTrue
func_call
tests/columns/foreign_key/test_attribute_access.py
test_recursion_limit
TestAttributeAccess
52
null
piccolo-orm/piccolo
import datetime from unittest import TestCase import pytest from piccolo.apps.user.tables import BaseUser from piccolo.columns import Date, Varchar from piccolo.columns.combination import WhereRaw from piccolo.query import OrderByRaw from piccolo.query.functions.aggregate import Avg, Count, Max, Min, Sum from piccolo...
[])
self.assertEqual
collection
tests/table/test_select.py
test_where_equals
TestSelect
104
null
piccolo-orm/piccolo
from __future__ import annotations import ast import asyncio from typing import cast from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.schema.commands.exceptions import GenerateError from piccolo.apps.schema.commands.generate import ( OutputSchema, generate, get_ou...
"self")
self.assertEqual
string_literal
tests/apps/schema/commands/test_generate.py
test_self_referencing_fk
TestGenerate
179
null
piccolo-orm/piccolo
import dataclasses import datetime from typing import Any from unittest import TestCase import pytest from piccolo.columns.base import Column from piccolo.columns.column_types import ( Date, Integer, Interval, Text, Timestamp, Timestamptz, Varchar, ) from piccolo.querystring import QuerySt...
"test 2")
self.assertEqual
string_literal
tests/table/test_update.py
test_update
TestAutoUpdate
655
null
piccolo-orm/piccolo
import datetime from unittest import TestCase from piccolo.columns import Date, ForeignKey, Varchar from piccolo.schema import SchemaManager from piccolo.table import Table, create_db_tables_sync from tests.base import engines_only class TestForeignKeyWithSchema(TestCase): schema_manager = SchemaManager() sc...
query.__str__())
self.assertIn
func_call
tests/columns/foreign_key/test_schema.py
test_with_schema
TestForeignKeyWithSchema
72
null
piccolo-orm/piccolo
import enum from piccolo.columns.column_types import Array, Varchar from piccolo.table import Table from piccolo.testing.test_case import TableTest from tests.example_apps.music.tables import Shirt class TestChoices(TableTest): tables = [Shirt] def _insert_shirts(self): Shirt.insert( Shir...
1)
self.assertEqual
numeric_literal
tests/columns/test_choices.py
test_objects_where
TestChoices
71
null
piccolo-orm/piccolo
from decimal import Decimal from piccolo.columns.column_types import Numeric from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestNumeric(TableTest): tables = [MyTable] def test_creation(self): row = MyTable(column_a=Decimal(1.23), column_b=Decimal(1.23)) ...
Decimal("1.23"))
self.assertAlmostEqual
func_call
tests/columns/test_numeric.py
test_creation
TestNumeric
27
null
piccolo-orm/piccolo
import datetime from piccolo.columns.column_types import Interval from piccolo.columns.defaults.interval import IntervalCustom from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestInterval(TableTest): tables = [MyTable] def test_interval_where_clause(self): """ ...
result)
self.assertIsNotNone
variable
tests/columns/test_interval.py
test_interval_where_clause
TestInterval
64
null
piccolo-orm/piccolo
from __future__ import annotations from unittest import TestCase from unittest.mock import MagicMock, call, patch from piccolo.apps.migrations.auto.schema_differ import ( DiffableTable, RenameColumn, RenameColumnCollection, RenameTable, RenameTableCollection, SchemaDiffer, ) from piccolo.colum...
1)
self.assertEqual
numeric_literal
tests/apps/migrations/auto/test_schema_differ.py
test_change_schema
TestSchemaDiffer
124
null
piccolo-orm/piccolo
import time from enum import Enum from unittest import TestCase import pytest from piccolo.columns.column_types import JSON, JSONB, Array, Integer, Varchar from piccolo.table import Table from piccolo.utils.sql_values import convert_to_sql_value class TestConvertToSQLValue(TestCase): def test_convert_enum_list(...
["r", "g", "b"])
self.assertEqual
collection
tests/utils/test_sql_values.py
test_convert_enum_list
TestConvertToSQLValue
79
null
piccolo-orm/piccolo
from piccolo.columns.column_types import UUID, Varchar from piccolo.table import Table from piccolo.testing.test_case import AsyncTableTest from tests.example_apps.music.tables import Manager class TestInstanceEquality(AsyncTableTest): tables = [ Manager, ManagerUUID, ] async def test_inst...
Manager())
self.assertNotEqual
func_call
tests/table/instance/test_equality.py
test_instance_equality
TestInstanceEquality
42
null
piccolo-orm/piccolo
import sys import pytest from piccolo.engine import engine_finder from piccolo.testing.test_case import ( AsyncTableTest, AsyncTransactionTest, TableTest, ) from tests.example_apps.music.tables import Band, Manager class TestAsyncTableTest(AsyncTableTest): tables = [Band, Manager] async def tes...
await Band.table_exists())
self.assertTrue
func_call
tests/testing/test_test_case.py
test_tables_created
TestAsyncTableTest
34
null
piccolo-orm/piccolo
import datetime from decimal import Decimal from unittest import TestCase from piccolo.columns.column_types import ( Array, BigInt, Date, Integer, Numeric, Time, Timestamp, Timestamptz, ) from piccolo.querystring import QueryString from piccolo.table import Table from piccolo.testing.te...
{"value": 1})
self.assertEqual
collection
tests/columns/test_array.py
test_index
TestArray
60
null
piccolo-orm/piccolo
import asyncio import random from io import StringIO from typing import Optional from unittest import IsolatedAsyncioTestCase, TestCase from unittest.mock import MagicMock, patch from piccolo.apps.migrations.auto.migration_manager import MigrationManager from piccolo.apps.migrations.commands.base import BaseMigrationM...
OnDelete.set_null)
self.assertEqual
complex_expr
tests/apps/migrations/auto/test_migration_manager.py
test_alter_fk_on_delete_on_update
TestMigrationManager
651
null
piccolo-orm/piccolo
from typing import Optional from piccolo.columns.column_types import ForeignKey, Integer, Serial, Varchar from piccolo.table import Table, create_db_tables_sync, drop_db_tables_sync from tests.base import DBTestCase, engine_is, engines_only class TestDBColumnName(DBTestCase): def setUp(self): create_db_t...
None
assert
none_literal
tests/columns/test_db_column_name.py
test_save
TestDBColumnName
64
null
piccolo-orm/piccolo
import os from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.migrations.commands.base import ( BaseMigrationManager, Migration, ) from piccolo.conf.apps import AppConfig from piccolo.utils.sync import run_sync class TestGetMigrationModules(TestCase): def test_get_mi...
len(migration_managers) == 1)
self.assertTrue
func_call
tests/apps/migrations/commands/test_base.py
test_get_migration_modules
TestGetMigrationModules
38
null
piccolo-orm/piccolo
from __future__ import annotations import ast import asyncio from typing import cast from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.schema.commands.exceptions import GenerateError from piccolo.apps.schema.commands.generate import ( OutputSchema, generate, get_ou...
IndexMethod.hash)
self.assertEqual
complex_expr
tests/apps/schema/commands/test_generate.py
test_index
TestGenerateWithIndexes
210
null
piccolo-orm/piccolo
import asyncio from piccolo.engine.finder import engine_finder ENGINE = engine_finder() async def drop_tables(): tables = [ "ticket", "concert", "venue", "band", "manager", "poster", "migration", "musician", "my_table", "recording_st...
None
assert
none_literal
tests/conftest.py
drop_tables
27
null
piccolo-orm/piccolo
from typing import cast from piccolo.testing.test_case import TableTest from tests.base import DBTestCase from tests.example_apps.music.tables import ( Band, Concert, Manager, RecordingStudio, Venue, ) class TestRefresh(DBTestCase): def setUp(self): super().setUp() self.insert_...
["name"])
self.assertEqual
collection
tests/table/test_refresh.py
test_columns
TestRefresh
102
null
piccolo-orm/piccolo
from typing import Optional from piccolo.columns.column_types import ( ForeignKey, LazyTableReference, Serial, Text, Varchar, ) from piccolo.columns.m2m import M2M from piccolo.engine.finder import engine_finder from piccolo.schema import SchemaManager from piccolo.table import Table, create_db_tab...
[])
self.assertEqual
collection
tests/columns/m2m/base.py
test_get_m2m_no_rows
M2MBase
419
null
piccolo-orm/piccolo
from enum import Enum from unittest import TestCase from piccolo.columns.choices import Choice from piccolo.columns.column_types import Integer, Varchar from piccolo.table import Table from tests.example_apps.music.tables import Band, Manager class TestEquals(TestCase): def test_non_column(self): """ ...
Manager.name._equals(value))
self.assertFalse
func_call
tests/columns/test_base.py
test_non_column
TestEquals
124
null
piccolo-orm/piccolo
from piccolo.columns.column_types import DoublePrecision from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestDoublePrecision(TableTest): tables = [MyTable] def test_creation(self): row = MyTable(column_a=1.23) row.save().run_sync() _row = MyTable....
None
assert
none_literal
tests/columns/test_double_precision.py
test_creation
TestDoublePrecision
18
null
piccolo-orm/piccolo
import decimal import uuid import warnings from enum import Enum from unittest import TestCase import pytest from piccolo.apps.migrations.auto.serialisation import ( CanConflictWithGlobalNames, Import, UniqueGlobalNameConflictWarning, UniqueGlobalNames, UniqueGlobalNamesMeta, serialise_params,...
1)
self.assertEqual
numeric_literal
tests/apps/migrations/auto/test_serialisation.py
test_custom_enum_instance
TestSerialiseParams
345
null
piccolo-orm/piccolo
import datetime from decimal import Decimal from unittest import TestCase from piccolo.columns.column_types import ( Array, BigInt, Date, Integer, Numeric, Time, Timestamp, Timestamptz, ) from piccolo.querystring import QueryString from piccolo.table import Table from piccolo.testing.te...
1)
self.assertEqual
numeric_literal
tests/columns/test_array.py
test_get_dimensions
TestGetDimensions
438
null
piccolo-orm/piccolo
import json from unittest import TestCase from piccolo.table import create_db_tables_sync, drop_db_tables_sync from tests.base import DBTestCase from tests.example_apps.music.tables import Band, Instrument, RecordingStudio class TestOutputLoadJSON(TestCase): tables = [RecordingStudio, Instrument] json = {"a":...
self.json)
self.assertEqual
complex_expr
tests/table/test_output.py
test_objects
TestOutputLoadJSON
130
null
piccolo-orm/piccolo
import dataclasses import datetime from typing import Any from unittest import TestCase import pytest from piccolo.columns.base import Column from piccolo.columns.column_types import ( Date, Integer, Interval, Text, Timestamp, Timestamptz, Varchar, ) from piccolo.querystring import QuerySt...
row.modified_on)
self.assertIsNone
complex_expr
tests/table/test_update.py
test_save
TestAutoUpdate
604
null
piccolo-orm/piccolo
from piccolo.columns.column_types import Integer, Varchar from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestReservedColumnNames(TableTest): tables = [Concert] def test_common_operations(self): # Save / Insert concert = Concert(name="Royal Albert Hall", ...
[])
self.assertEqual
collection
tests/columns/test_reserved_column_names.py
test_common_operations
TestReservedColumnNames
52
null
piccolo-orm/piccolo
import decimal import unittest from enum import Enum from piccolo.testing.random_builder import RandomBuilder class TestRandomBuilder(unittest.TestCase): def test_next_decimal(self): random_decimal = RandomBuilder.next_decimal(precision=4, scale=2) self.assertLessEqual(random_decimal,
decimal.Decimal("99.99"))
self.assertLessEqual
func_call
tests/testing/test_random_builder.py
test_next_decimal
TestRandomBuilder
41
null
piccolo-orm/piccolo
from __future__ import annotations from unittest import TestCase from unittest.mock import MagicMock, call, patch from piccolo.apps.migrations.auto.schema_differ import ( DiffableTable, RenameColumn, RenameColumnCollection, RenameTable, RenameTableCollection, SchemaDiffer, ) from piccolo.colum...
"Manager")
self.assertEqual
string_literal
tests/apps/migrations/auto/test_schema_differ.py
test_renamed_from
TestRenameTableCollection
515
null
piccolo-orm/piccolo
import decimal from typing import Optional, cast from unittest import TestCase import pydantic import pydantic_core import pytest from pydantic import ValidationError from piccolo.columns import ( JSON, JSONB, UUID, Array, Email, Integer, Numeric, Secret, Text, Time, Timest...
output)
self.assertEqual
variable
tests/utils/test_pydantic.py
test_deserialize_json
TestJSONColumn
398
null
piccolo-orm/piccolo
import os from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.tester.commands.run import run, set_env_var class TestRun(TestCase): @patch("piccolo.apps.tester.commands.run.run_pytest") @patch("piccolo.apps.tester.commands.run.refresh_db") def test_success(self, refre...
["-s", "foo"])
assert_*
collection
tests/apps/tester/commands/test_run.py
test_success
TestRun
74
null
piccolo-orm/piccolo
from typing import TYPE_CHECKING, Any, Optional from typing_extensions import assert_type from piccolo.columns import ForeignKey, Varchar from piccolo.testing.model_builder import ModelBuilder from piccolo.utils.sync import run_sync from .example_apps.music.tables import Band, Concert, Manager async def get_or_...
Band)
assert_*
variable
tests/type_checking.py
get_or_create
61
null
piccolo-orm/piccolo
import decimal from typing import Optional, cast from unittest import TestCase import pydantic import pydantic_core import pytest from pydantic import ValidationError from piccolo.columns import ( JSON, JSONB, UUID, Array, Email, Integer, Numeric, Secret, Text, Time, Timest...
"time")
self.assertEqual
string_literal
tests/utils/test_pydantic.py
test_time_format
TestTimeColumn
224
null
piccolo-orm/piccolo
from enum import Enum from unittest import TestCase from piccolo.columns.choices import Choice from piccolo.columns.column_types import Integer, Varchar from piccolo.table import Table from tests.example_apps.music.tables import Band, Manager class TestCopy(TestCase): def test_copy(self): """ Try ...
id(new_column))
self.assertNotEqual
func_call
tests/columns/test_base.py
test_copy
TestCopy
21
null
piccolo-orm/piccolo
import enum from piccolo.columns.column_types import Array, Varchar from piccolo.table import Table from piccolo.testing.test_case import TableTest from tests.example_apps.music.tables import Shirt class TestChoices(TableTest): tables = [Shirt] def _insert_shirts(self): Shirt.insert( Shir...
["l", "m", "l"])
self.assertEqual
collection
tests/columns/test_choices.py
test_update
TestChoices
49
null
piccolo-orm/piccolo
from piccolo.columns.column_types import Bytea from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestByteaDefault(TableTest): tables = [MyTableDefault] def test_json_default(self): row = MyTableDefault() row.save().run_sync() self.assertEqual(row.t...
b"")
self.assertEqual
string_literal
tests/columns/test_bytea.py
test_json_default
TestByteaDefault
45
null
piccolo-orm/piccolo
import decimal from unittest import TestCase from tests.base import engine_is from tests.example_apps.music.tables import ( Band, Concert, Manager, Signing, Ticket, Venue, ) TABLES = [Manager, Band, Venue, Concert] class TestJoin(TestCase): tables = [Manager, Band, Venue, Concert, Ticket,...
int)
self.assertIsInstance
variable
tests/table/test_join.py
test_objects_prefetch_intermediate
TestJoin
444
null
piccolo-orm/piccolo
from piccolo.columns.column_types import JSONB, ForeignKey, Varchar from piccolo.table import Table from piccolo.testing.test_case import AsyncTableTest, TableTest from tests.base import engines_only class TestArrow(AsyncTableTest): tables = [RecordingStudio, Instrument] async def insert_row(self): aw...
"true")
self.assertEqual
string_literal
tests/columns/test_jsonb.py
test_arrow
TestArrow
160
null
piccolo-orm/piccolo
from __future__ import annotations import ast import asyncio from typing import cast from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.schema.commands.exceptions import GenerateError from piccolo.apps.schema.commands.generate import ( OutputSchema, generate, get_ou...
None
assert
none_literal
tests/apps/schema/commands/test_generate.py
test_get_output_schema
TestGenerate
78
null
piccolo-orm/piccolo
from piccolo.columns.column_types import JSONB, ForeignKey, Varchar from piccolo.table import Table from piccolo.testing.test_case import AsyncTableTest, TableTest from tests.base import engines_only class TestArrow(AsyncTableTest): tables = [RecordingStudio, Instrument] async def insert_row(self): aw...
1)
self.assertEqual
numeric_literal
tests/columns/test_jsonb.py
test_arrow_where
TestArrow
228
null
piccolo-orm/piccolo
from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.columns.column_types import ( JSON, JSONB, Array, Email, ForeignKey, Secret, Varchar, ) from piccolo.table import TABLENAME_WARNING, Table from tests.example_apps.music.tables import Band class TestMetaCl...
table)
self.assertEqual
variable
tests/table/test_metaclass.py
test_schema_from_tablename
TestMetaClass
78
null
piccolo-orm/piccolo
from __future__ import annotations import datetime import decimal import os import random import shutil import tempfile import time import uuid from collections.abc import Callable from typing import TYPE_CHECKING, Optional from unittest.mock import MagicMock, patch from piccolo.apps.migrations.auto.operations import...
["manager"])
self.assertListEqual
collection
tests/apps/migrations/auto/integration/test_migrations.py
test_create_table_in_schema
TestSchemas
1,217
null
piccolo-orm/piccolo
from __future__ import annotations import pathlib import tempfile from unittest import TestCase from piccolo.apps.user.tables import BaseUser from piccolo.conf.apps import ( AppConfig, AppRegistry, Finder, PiccoloConfUpdater, table_finder, ) from tests.example_apps.mega.tables import MegaTable, Sm...
["Musician"])
self.assertEqual
collection
tests/conf/test_apps.py
test_exclude_imported
TestTableFinder
217
null
piccolo-orm/piccolo
import uuid from piccolo.columns.column_types import ( UUID, BigSerial, ForeignKey, Serial, Varchar, ) from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestPrimaryKeyUUID(TableTest): tables = [MyTablePrimaryKeyUUID] def test_return_type(self): ...
UUID)
self.assertIsInstance
variable
tests/columns/test_primary_key.py
test_return_type
TestPrimaryKeyUUID
73
null
piccolo-orm/piccolo
from __future__ import annotations import sys from typing import TYPE_CHECKING from unittest import TestCase from unittest.mock import MagicMock, call, patch from piccolo.apps.migrations.commands.backwards import backwards from piccolo.apps.migrations.commands.forwards import forwards from piccolo.apps.migrations.tab...
print_.mock_calls)
self.assertNotIn
complex_expr
tests/apps/migrations/commands/test_forwards_backwards.py
test_hardcoded_fake_migrations
TestForwardsBackwards
245
null
piccolo-orm/piccolo
import secrets from unittest import TestCase from unittest.mock import MagicMock, call, patch from piccolo.apps.user.tables import BaseUser class TestCreateUser(TestCase): def setUp(self): BaseUser.create_table().run_sync() def tearDown(self): BaseUser.alter().drop_table().run_sync() def...
user.id)
self.assertEqual
complex_expr
tests/apps/user/test_tables.py
test_success
TestCreateUser
183
null
piccolo-orm/piccolo
from __future__ import annotations from typing import Any, Union from unittest import TestCase import pytest from piccolo.columns import BigInt, Integer, Numeric, Varchar from piccolo.columns.base import Column from piccolo.columns.column_types import ForeignKey, Text from piccolo.schema import SchemaManager from pi...
"NO")
self.assertEqual
string_literal
tests/table/test_alter.py
test_set_null
TestSetNull
293
null
piccolo-orm/piccolo
import os import tempfile from unittest import TestCase from piccolo.apps.project.commands.new import new class TestNewProject(TestCase): def test_new(self): root = tempfile.gettempdir() file_path = os.path.join(root, "piccolo_conf.py") if os.path.exists(file_path): os.unlink...
os.path.exists(file_path))
self.assertTrue
func_call
tests/apps/project/commands/test_new.py
test_new
TestNewProject
19
null
piccolo-orm/piccolo
import asyncio import enum import json import unittest from piccolo.columns import ( Array, Decimal, ForeignKey, Integer, LazyTableReference, Numeric, Real, Timestamp, Timestamptz, Varchar, ) from piccolo.table import Table, create_db_tables_sync, drop_db_tables_sync from piccol...
"Guido")
self.assertEqual
string_literal
tests/testing/test_model_builder.py
test_valid_column
TestModelBuilder
190
null
piccolo-orm/piccolo
import asyncio import enum import json import unittest from piccolo.columns import ( Array, Decimal, ForeignKey, Integer, LazyTableReference, Numeric, Real, Timestamp, Timestamptz, Varchar, ) from piccolo.table import Table, create_db_tables_sync, drop_db_tables_sync from piccol...
band.manager)
self.assertEqual
complex_expr
tests/testing/test_model_builder.py
test_valid_foreign_key
TestModelBuilder
210
null
piccolo-orm/piccolo
import asyncio import enum import json import unittest from piccolo.columns import ( Array, Decimal, ForeignKey, Integer, LazyTableReference, Numeric, Real, Timestamp, Timestamptz, Varchar, ) from piccolo.table import Table, create_db_tables_sync, drop_db_tables_sync from piccol...
["s", "l", "m"])
self.assertIn
collection
tests/testing/test_model_builder.py
test_choices
TestModelBuilder
105
null
piccolo-orm/piccolo
from unittest.mock import Mock from tests.base import AsyncMock, DBTestCase from tests.example_apps.music.tables import Band def identity(x): """Returns the input. Used as the side effect for mock callbacks.""" return x def get_name(results): return results["name"] async def uppercase(name): """Asyn...
list)
self.assertIsInstance
variable
tests/table/test_callback.py
test_callback_sync
TestCallbackSuccessesObjects
72
null
piccolo-orm/piccolo
from __future__ import annotations import ast import asyncio from typing import cast from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.schema.commands.exceptions import GenerateError from piccolo.apps.schema.commands.generate import ( OutputSchema, generate, get_ou...
col_2._meta.null)
self.assertEqual
complex_expr
tests/apps/schema/commands/test_generate.py
_compare_table_columns
TestGenerate
58
null
piccolo-orm/piccolo
import datetime from decimal import Decimal from unittest import TestCase from piccolo.columns.column_types import ( Array, BigInt, Date, Integer, Numeric, Time, Timestamp, Timestamptz, ) from piccolo.querystring import QueryString from piccolo.table import Table from piccolo.testing.te...
int)
self.assertEqual
variable
tests/columns/test_array.py
test_get_inner_value_type
TestGetInnerValueType
448
null
piccolo-orm/piccolo
from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.columns.column_types import ( JSON, JSONB, Array, Email, ForeignKey, Secret, Varchar, ) from piccolo.table import TABLENAME_WARNING, Table from tests.example_apps.music.tables import Band class TestMetaCl...
schema)
self.assertEqual
variable
tests/table/test_metaclass.py
test_schema
TestMetaClass
62
null
piccolo-orm/piccolo
from typing import TYPE_CHECKING, Any, Optional from typing_extensions import assert_type from piccolo.columns import ForeignKey, Varchar from piccolo.testing.model_builder import ModelBuilder from piccolo.utils.sync import run_sync from .example_apps.music.tables import Band, Concert, Manager async def get_rel...
None
assert
none_literal
tests/type_checking.py
get_related
49
null
piccolo-orm/piccolo
import asyncio from unittest import TestCase from piccolo.columns.column_types import Varchar from piccolo.engine.exceptions import TransactionError from piccolo.engine.sqlite import SQLiteEngine from piccolo.table import Table from tests.base import DBTestCase, sqlite_only from tests.example_apps.music.tables import ...
"Dave")
self.assertEqual
string_literal
tests/engine/test_nested_transaction.py
run_nested
TestDifferentDB
54
null
piccolo-orm/piccolo
from typing import TYPE_CHECKING, Any, Optional from typing_extensions import assert_type from piccolo.columns import ForeignKey, Varchar from piccolo.testing.model_builder import ModelBuilder from piccolo.utils.sync import run_sync from .example_apps.music.tables import Band, Concert, Manager async def exists(...
bool)
assert_*
variable
tests/type_checking.py
exists
93
null
piccolo-orm/piccolo
from typing import Optional from piccolo.columns.column_types import ( ForeignKey, LazyTableReference, Serial, Text, Varchar, ) from piccolo.columns.m2m import M2M from piccolo.engine.finder import engine_finder from piccolo.schema import SchemaManager from piccolo.table import Table, create_db_tab...
True
assert
bool_literal
tests/columns/m2m/base.py
assertTrue
M2MBase
85
null
piccolo-orm/piccolo
import dataclasses import datetime from typing import Any from unittest import TestCase import pytest from piccolo.columns.base import Column from piccolo.columns.column_types import ( Date, Integer, Interval, Text, Timestamp, Timestamptz, Varchar, ) from piccolo.querystring import QuerySt...
starts)
self.assertEqual
variable
tests/table/test_update.py
test_db_column_name
TestDBColumnName
801
null
piccolo-orm/piccolo
from __future__ import annotations from typing import Any, Union from unittest import TestCase import pytest from piccolo.columns import BigInt, Integer, Numeric, Varchar from piccolo.columns.base import Column from piccolo.columns.column_types import ForeignKey, Text from piccolo.schema import SchemaManager from pi...
"YES")
self.assertEqual
string_literal
tests/table/test_alter.py
test_set_null
TestSetNull
289
null
piccolo-orm/piccolo
import uuid from piccolo.columns.column_types import ( UUID, BigSerial, ForeignKey, Serial, Varchar, ) from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestPrimaryKeyDefault(TableTest): tables = [MyTableDefaultPrimaryKey] def test_return_type(self): ...
Serial)
self.assertIsInstance
variable
tests/columns/test_primary_key.py
test_return_type
TestPrimaryKeyDefault
40
null
piccolo-orm/piccolo
from piccolo.columns.column_types import JSON from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestJSONDefault(TableTest): tables = [MyTableDefault] def test_json_default(self): row = MyTableDefault() row.save().run_sync() self.assertEqual(row.jso...
"{}")
self.assertEqual
string_literal
tests/columns/test_json.py
test_json_default
TestJSONDefault
63
null
piccolo-orm/piccolo
import uuid from piccolo.columns.column_types import UUID from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestUUID(TableTest): tables = [MyTable] def test_return_type(self): row = MyTable() row.save().run_sync() self.assertIsInstance(row.uuid,
uuid.UUID)
self.assertIsInstance
complex_expr
tests/columns/test_uuid.py
test_return_type
TestUUID
19
null
piccolo-orm/piccolo
import decimal from typing import Optional, cast from unittest import TestCase import pydantic import pydantic_core import pytest from pydantic import ValidationError from piccolo.columns import ( JSON, JSONB, UUID, Array, Email, Integer, Numeric, Secret, Text, Time, Timest...
"json")
self.assertEqual
string_literal
tests/utils/test_pydantic.py
test_json_widget
TestJSONColumn
435
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.apps.migrations.auto.diffable_table import ( DiffableTable, compare_dicts, ) from piccolo.columns import OnDelete, Varchar class TestDiffableTable(TestCase): def test_subtract(self): kwargs = {"class_name": "Manager", "tablename": "manager"} name...
{"unique": False})
self.assertEqual
collection
tests/apps/migrations/auto/test_diffable_table.py
test_subtract
TestDiffableTable
105
null
piccolo-orm/piccolo
from piccolo.columns import ForeignKey, Varchar from piccolo.columns.base import OnDelete, OnUpdate from piccolo.query.constraints import get_fk_constraint_rules from piccolo.table import Table from piccolo.testing.test_case import AsyncTableTest from tests.base import engines_only class TestOnDeleteOnUpdate(AsyncTabl...
OnDelete.set_null)
self.assertEqual
complex_expr
tests/columns/foreign_key/test_on_delete_on_update.py
test_on_delete_on_update
TestOnDeleteOnUpdate
36
null
piccolo-orm/piccolo
import asyncio import random from io import StringIO from typing import Optional from unittest import IsolatedAsyncioTestCase, TestCase from unittest.mock import MagicMock, patch from piccolo.apps.migrations.auto.migration_manager import MigrationManager from piccolo.apps.migrations.commands.base import BaseMigrationM...
[{"id": 1}])
self.assertEqual
collection
tests/apps/migrations/auto/test_migration_manager.py
test_drop_column
TestMigrationManager
557
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.apps.migrations.auto import MigrationManager, SchemaSnapshot class TestSchemaSnaphot(TestCase): def test_drop_column(self): """ Test dropping columns. """ manager_1 = MigrationManager() manager_1.add_table(class_name="Manager", ta...
0)
self.assertEqual
numeric_literal
tests/apps/migrations/auto/test_schema_snapshot.py
test_drop_column
TestSchemaSnaphot
148
null
piccolo-orm/piccolo
import decimal import unittest from enum import Enum from piccolo.testing.random_builder import RandomBuilder class TestRandomBuilder(unittest.TestCase): def test_next_bool(self): random_bool = RandomBuilder.next_bool() self.assertIn(random_bool,
[True, False])
self.assertIn
collection
tests/testing/test_random_builder.py
test_next_bool
TestRandomBuilder
11
null
piccolo-orm/piccolo
from __future__ import annotations import ast import asyncio from typing import cast from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.schema.commands.exceptions import GenerateError from piccolo.apps.schema.commands.generate import ( OutputSchema, generate, get_ou...
1)
self.assertEqual
numeric_literal
tests/apps/schema/commands/test_generate.py
test_generate_required_tables
TestGenerate
137
null
piccolo-orm/piccolo
import asyncio import random from io import StringIO from typing import Optional from unittest import IsolatedAsyncioTestCase, TestCase from unittest.mock import MagicMock, patch from piccolo.apps.migrations.auto.migration_manager import MigrationManager from piccolo.apps.migrations.commands.base import BaseMigrationM...
HasRun)
self.assertRaises
variable
tests/apps/migrations/auto/test_migration_manager.py
test_raw_function
TestMigrationManager
179
null
piccolo-orm/piccolo
from __future__ import annotations import ast import asyncio from typing import cast from unittest import TestCase from unittest.mock import MagicMock, patch from piccolo.apps.schema.commands.exceptions import GenerateError from piccolo.apps.schema.commands.generate import ( OutputSchema, generate, get_ou...
3)
self.assertEqual
numeric_literal
tests/apps/schema/commands/test_generate.py
test_reference_to_another_schema
TestGenerateWithSchema
263
null
piccolo-orm/piccolo
import datetime from piccolo.columns.column_types import Interval from piccolo.columns.defaults.interval import IntervalCustom from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestIntervalDefault(TableTest): tables = [MyTableDefault] def test_interval(self): row =...
1)
self.assertEqual
numeric_literal
tests/columns/test_interval.py
test_interval
TestIntervalDefault
99
null
piccolo-orm/piccolo
import enum from piccolo.columns.column_types import Array, Varchar from piccolo.table import Table from piccolo.testing.test_case import TableTest from tests.example_apps.music.tables import Shirt class TestChoices(TableTest): tables = [Shirt] def _insert_shirts(self): Shirt.insert( Shir...
"s")
self.assertEqual
string_literal
tests/columns/test_choices.py
test_objects_where
TestChoices
72
null
piccolo-orm/piccolo
import os import shutil import tempfile from unittest import TestCase from piccolo.apps.app.commands.new import ( get_app_module, module_exists, new, validate_app_name, ) class TestNewApp(TestCase): def test_new(self): root = tempfile.gettempdir() app_name = "my_app" app_p...
os.path.exists(app_path))
self.assertTrue
func_call
tests/apps/app/commands/test_new.py
test_new
TestNewApp
32
null
piccolo-orm/piccolo
from unittest.mock import Mock from tests.base import AsyncMock, DBTestCase from tests.example_apps.music.tables import Band def identity(x): """Returns the input. Used as the side effect for mock callbacks.""" return x def get_name(results): return results["name"] async def uppercase(name): """Asyn...
Band)
self.assertIsInstance
variable
tests/table/test_callback.py
test_callback_sync
TestCallbackSuccessesObjects
73
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.apps.migrations.auto.diffable_table import ( DiffableTable, compare_dicts, ) from piccolo.columns import OnDelete, Varchar class TestCompareDicts(TestCase): def test_missing_keys(self): """ Make sure that if one dictionary has keys that the other...
{"a": 1})
self.assertEqual
collection
tests/apps/migrations/auto/test_diffable_table.py
test_missing_keys
TestCompareDicts
28
null
piccolo-orm/piccolo
from piccolo.columns.column_types import Integer, Varchar from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestReservedColumnNames(TableTest): tables = [Concert] def test_common_operations(self): # Save / Insert concert = Concert(name="Royal Albert Hall", ...
[{"order": 3}])
self.assertEqual
collection
tests/columns/test_reserved_column_names.py
test_common_operations
TestReservedColumnNames
45
null
piccolo-orm/piccolo
from decimal import Decimal from piccolo.columns.column_types import Numeric from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestNumeric(TableTest): tables = [MyTable] def test_creation(self): row = MyTable(column_a=Decimal(1.23), column_b=Decimal(1.23)) ...
Decimal(1.23))
self.assertAlmostEqual
func_call
tests/columns/test_numeric.py
test_creation
TestNumeric
26
null
piccolo-orm/piccolo
import enum from piccolo.columns.column_types import Array, Varchar from piccolo.table import Table from piccolo.testing.test_case import TableTest from tests.example_apps.music.tables import Shirt class TestChoices(TableTest): tables = [Shirt] def _insert_shirts(self): Shirt.insert( Shir...
[{"size": "s"}])
self.assertEqual
collection
tests/columns/test_choices.py
test_select_where
TestChoices
61
null
piccolo-orm/piccolo
from __future__ import annotations from typing import Any, Union from unittest import TestCase import pytest from piccolo.columns import BigInt, Integer, Numeric, Varchar from piccolo.columns.base import Column from piccolo.columns.column_types import ForeignKey, Text from piccolo.schema import SchemaManager from pi...
length)
self.assertEqual
variable
tests/table/test_alter.py
test_set_length
TestSetLength
309
null
piccolo-orm/piccolo
import uuid from piccolo.columns.column_types import ( UUID, BigSerial, ForeignKey, Serial, Varchar, ) from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestPrimaryKeyQueries(TableTest): tables = [Manager, Band] def test_primary_key_queries(self): ...
uuid.UUID)
self.assertIsInstance
complex_expr
tests/columns/test_primary_key.py
test_primary_key_queries
TestPrimaryKeyQueries
121
null
piccolo-orm/piccolo
import asyncio import math from unittest import TestCase from piccolo.columns import Varchar from piccolo.engine.finder import engine_finder from piccolo.engine.postgres import AsyncBatch, PostgresEngine from piccolo.table import Table from piccolo.utils.sync import run_sync from tests.base import AsyncMock, DBTestCas...
list)
self.assertEqual
variable
tests/table/test_batch.py
_check_results
TestBatchSelect
19
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.apps.migrations.auto.diffable_table import ( DiffableTable, compare_dicts, ) from piccolo.columns import OnDelete, Varchar class TestCompareDicts(TestCase): def test_simple(self): """ Make sure that simple values are compared properly. """...
{"b": 2})
self.assertEqual
collection
tests/apps/migrations/auto/test_diffable_table.py
test_simple
TestCompareDicts
18
null
piccolo-orm/piccolo
from __future__ import annotations import datetime import decimal import os import random import shutil import tempfile import time import uuid from collections.abc import Callable from typing import TYPE_CHECKING, Optional from unittest.mock import MagicMock, patch from piccolo.apps.migrations.auto.operations import...
test_function(row_meta))
self.assertTrue
func_call
tests/apps/migrations/auto/integration/test_migrations.py
_test_migrations
MigrationTestCase
181
null
piccolo-orm/piccolo
import datetime import decimal import os import tempfile import uuid from unittest import TestCase from piccolo.apps.fixtures.commands.dump import ( FixtureConfig, dump_to_json_string, ) from piccolo.apps.fixtures.commands.load import load, load_json_string from piccolo.utils.sync import run_sync from tests.ba...
len(mega_table_data) == 1)
self.assertTrue
func_call
tests/apps/fixtures/commands/test_dump_load.py
_run_comparison
TestDumpLoad
111
null
piccolo-orm/piccolo
from __future__ import annotations from typing import Any, Union from unittest import TestCase import pytest from piccolo.columns import BigInt, Integer, Numeric, Varchar from piccolo.columns.base import Column from piccolo.columns.column_types import ForeignKey, Text from piccolo.schema import SchemaManager from pi...
"Pending")
self.assertEqual
string_literal
tests/table/test_alter.py
test_set_default
TestSetDefault
324
null
piccolo-orm/piccolo
from piccolo.columns.column_types import ForeignKey from piccolo.testing.test_case import AsyncTableTest from tests.base import DBTestCase, engines_only, sqlite_only from tests.example_apps.music.tables import Band, Manager class TestGetOrCreate(DBTestCase): def test_simple_where_clause(self): """ ...
Band)
self.assertIsInstance
variable
tests/table/test_objects.py
test_simple_where_clause
TestGetOrCreate
114
null
piccolo-orm/piccolo
from __future__ import annotations import pathlib import tempfile from unittest import TestCase from piccolo.apps.user.tables import BaseUser from piccolo.conf.apps import ( AppConfig, AppRegistry, Finder, PiccoloConfUpdater, table_finder, ) from tests.example_apps.mega.tables import MegaTable, Sm...
["Poster"])
self.assertEqual
collection
tests/conf/test_apps.py
test_include_tags
TestTableFinder
176
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.querystring import QueryString class TestQueryString(TestCase): qs = QueryString( "SELECT id FROM band {}", QueryString("WHERE name = {}", "Pythonistas") ) def test_compile_string(self): compiled_string, args = self.qs.compile_string() ...
["Pythonistas"])
self.assertEqual
collection
tests/query/test_querystring.py
test_compile_string
TestQueryString
20
null
piccolo-orm/piccolo
import sqlite3 from unittest import TestCase import pytest from piccolo.columns import Integer, Serial, Varchar from piccolo.query.methods.insert import OnConflictAction from piccolo.table import Table from piccolo.utils.lazy_loader import LazyLoader from tests.base import ( DBTestCase, engine_version_lt, ...
[{"name": "Maz"}])
self.assertListEqual
collection
tests/table/test_insert.py
test_insert_returning
TestInsert
76
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.columns import Varchar from piccolo.table import Table from piccolo.table_reflection import TableStorage from piccolo.utils.sync import run_sync from tests.base import engines_only from tests.example_apps.music.tables import Band, Manager class TestTableStorage(TestCase): ...
"music")
self.assertEqual
string_literal
tests/utils/test_table_reflection.py
test_get_schema_and_table_name
TestTableStorage
92
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.utils.naming import _camel_to_snake class TestCamelToSnake(TestCase): def test_converting_tablenames(self): """ Make sure Table names are converted correctly. """ self.assertEqual(_camel_to_snake("HelloWorld"), "hello_world") self...
"manager1")
self.assertEqual
string_literal
tests/utils/test_naming.py
test_converting_tablenames
TestCamelToSnake
12
null
piccolo-orm/piccolo
from typing import Any from piccolo.columns.column_types import Boolean from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestBoolean(TableTest): tables = [MyTable] def test_eq_and_ne(self): """ Make sure the `eq` and `ne` methods works correctly. "...
1)
self.assertEqual
numeric_literal
tests/columns/test_boolean.py
test_eq_and_ne
TestBoolean
54
null
piccolo-orm/piccolo
from piccolo.columns.column_types import DoublePrecision from piccolo.table import Table from piccolo.testing.test_case import TableTest class TestDoublePrecision(TableTest): tables = [MyTable] def test_creation(self): row = MyTable(column_a=1.23) row.save().run_sync() _row = MyTable....
float)
self.assertEqual
variable
tests/columns/test_double_precision.py
test_creation
TestDoublePrecision
19
null
piccolo-orm/piccolo
from unittest import TestCase from piccolo.columns import JSONB from piccolo.query.operators.json import GetChildElement, GetElementFromPath from piccolo.table import Table from tests.base import engines_skip class TestGetElementFromPath(TestCase): def test_query(self): """ Make sure the generate...
[["a", "b"]])
self.assertListEqual
collection
tests/query/operators/test_json.py
test_query
TestGetElementFromPath
52
null