Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions tests/schema_alter.py

This file was deleted.

108 changes: 58 additions & 50 deletions tests/test_alter.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,71 @@
import pytest
import re
import datajoint as dj
from . import schema as schema_any_module, schema_alter as schema_alter_module, PREFIX
from .schema_alter import Parent, Experiment
from . import schema as schema_any_module, PREFIX


class Experiment(dj.Imported):
original_definition = """ # information about experiments
-> Subject
experiment_id :smallint # experiment number for this subject
---
experiment_date :date # date when experiment was started
-> [nullable] User
data_path="" :varchar(255) # file path to recorded data
notes="" :varchar(2048) # e.g. purpose of experiment
entry_time=CURRENT_TIMESTAMP :timestamp # automatic timestamp
"""

definition1 = """ # Experiment
-> Subject
experiment_id :smallint # experiment number for this subject
---
data_path : int # some number
extra=null : longblob # just testing
-> [nullable] User
subject_notes=null :varchar(2048) # {notes} e.g. purpose of experiment
entry_time=CURRENT_TIMESTAMP :timestamp # automatic timestamp
"""


class Parent(dj.Manual):
definition = """
parent_id: int
"""

class Child(dj.Part):
definition = """
-> Parent
"""
definition_new = """
-> master
---
child_id=null: int
"""

class Grandchild(dj.Part):
definition = """
-> master.Child
"""
definition_new = """
-> master.Child
---
grandchild_id=null: int
"""


LOCALS_ALTER = {"Experiment": Experiment, "Parent": Parent}
COMBINED_CONTEXT = {
**schema_any_module.LOCALS_ANY,
**schema_alter_module.LOCALS_ALTER,
**LOCALS_ALTER,
}


@pytest.fixture
def schema_alter(connection_test):
schema_any = dj.Schema(
PREFIX + "_alter",
context=schema_any_module.LOCALS_ANY,
connection=connection_test,
)
schema_any(schema_any_module.TTest)
schema_any(schema_any_module.TTest2)
schema_any(schema_any_module.TTest3)
schema_any(schema_any_module.NullableNumbers)
schema_any(schema_any_module.TTestExtra)
schema_any(schema_any_module.TTestNoExtra)
schema_any(schema_any_module.Auto)
schema_any(schema_any_module.User)
schema_any(schema_any_module.Subject)
schema_any(schema_any_module.Language)
schema_any(schema_any_module.Experiment)
schema_any(schema_any_module.Trial)
schema_any(schema_any_module.Ephys)
schema_any(schema_any_module.Image)
schema_any(schema_any_module.UberTrash)
schema_any(schema_any_module.UnterTrash)
schema_any(schema_any_module.SimpleSource)
schema_any(schema_any_module.SigIntTable)
schema_any(schema_any_module.SigTermTable)
schema_any(schema_any_module.DjExceptionName)
schema_any(schema_any_module.ErrorClass)
schema_any(schema_any_module.DecimalPrimaryKey)
schema_any(schema_any_module.IndexRich)
schema_any(schema_any_module.ThingA)
schema_any(schema_any_module.ThingB)
schema_any(schema_any_module.ThingC)
schema_any(schema_any_module.Parent)
schema_any(schema_any_module.Child)
schema_any(schema_any_module.ComplexParent)
schema_any(schema_any_module.ComplexChild)
schema_any(schema_any_module.SubjectA)
schema_any(schema_any_module.SessionA)
schema_any(schema_any_module.SessionStatusA)
schema_any(schema_any_module.SessionDateA)
schema_any(schema_any_module.Stimulus)
schema_any(schema_any_module.Longblob)

# Add nodes from schema_alter_module
schema_any(Experiment, context=schema_alter_module.LOCALS_ALTER)
schema_any(Parent, context=schema_alter_module.LOCALS_ALTER)

def schema_alter(connection_test, schema_any):
# Overwrite Experiment and Parent nodes
schema_any(Experiment, context=LOCALS_ALTER)
schema_any(Parent, context=LOCALS_ALTER)
yield schema_any
schema_any.drop()

Expand Down
Loading