Skip to content

Commit 8ca30bd

Browse files
committed
Merge remote-tracking branch 'upstream/dev-tests' into dev-tests-plat-153-declare
2 parents 775521f + 3baa4f4 commit 8ca30bd

File tree

2 files changed

+58
-108
lines changed

2 files changed

+58
-108
lines changed

tests/schema_alter.py

Lines changed: 0 additions & 58 deletions
This file was deleted.

tests/test_alter.py

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,71 @@
11
import pytest
22
import re
33
import datajoint as dj
4-
from . import schema as schema_any_module, schema_alter as schema_alter_module, PREFIX
5-
from .schema_alter import Parent, Experiment
4+
from . import schema as schema_any_module, PREFIX
65

6+
7+
class Experiment(dj.Imported):
8+
original_definition = """ # information about experiments
9+
-> Subject
10+
experiment_id :smallint # experiment number for this subject
11+
---
12+
experiment_date :date # date when experiment was started
13+
-> [nullable] User
14+
data_path="" :varchar(255) # file path to recorded data
15+
notes="" :varchar(2048) # e.g. purpose of experiment
16+
entry_time=CURRENT_TIMESTAMP :timestamp # automatic timestamp
17+
"""
18+
19+
definition1 = """ # Experiment
20+
-> Subject
21+
experiment_id :smallint # experiment number for this subject
22+
---
23+
data_path : int # some number
24+
extra=null : longblob # just testing
25+
-> [nullable] User
26+
subject_notes=null :varchar(2048) # {notes} e.g. purpose of experiment
27+
entry_time=CURRENT_TIMESTAMP :timestamp # automatic timestamp
28+
"""
29+
30+
31+
class Parent(dj.Manual):
32+
definition = """
33+
parent_id: int
34+
"""
35+
36+
class Child(dj.Part):
37+
definition = """
38+
-> Parent
39+
"""
40+
definition_new = """
41+
-> master
42+
---
43+
child_id=null: int
44+
"""
45+
46+
class Grandchild(dj.Part):
47+
definition = """
48+
-> master.Child
49+
"""
50+
definition_new = """
51+
-> master.Child
52+
---
53+
grandchild_id=null: int
54+
"""
55+
56+
57+
LOCALS_ALTER = {"Experiment": Experiment, "Parent": Parent}
758
COMBINED_CONTEXT = {
859
**schema_any_module.LOCALS_ANY,
9-
**schema_alter_module.LOCALS_ALTER,
60+
**LOCALS_ALTER,
1061
}
1162

1263

1364
@pytest.fixture
14-
def schema_alter(connection_test):
15-
schema_any = dj.Schema(
16-
PREFIX + "_alter",
17-
context=schema_any_module.LOCALS_ANY,
18-
connection=connection_test,
19-
)
20-
schema_any(schema_any_module.TTest)
21-
schema_any(schema_any_module.TTest2)
22-
schema_any(schema_any_module.TTest3)
23-
schema_any(schema_any_module.NullableNumbers)
24-
schema_any(schema_any_module.TTestExtra)
25-
schema_any(schema_any_module.TTestNoExtra)
26-
schema_any(schema_any_module.Auto)
27-
schema_any(schema_any_module.User)
28-
schema_any(schema_any_module.Subject)
29-
schema_any(schema_any_module.Language)
30-
schema_any(schema_any_module.Experiment)
31-
schema_any(schema_any_module.Trial)
32-
schema_any(schema_any_module.Ephys)
33-
schema_any(schema_any_module.Image)
34-
schema_any(schema_any_module.UberTrash)
35-
schema_any(schema_any_module.UnterTrash)
36-
schema_any(schema_any_module.SimpleSource)
37-
schema_any(schema_any_module.SigIntTable)
38-
schema_any(schema_any_module.SigTermTable)
39-
schema_any(schema_any_module.DjExceptionName)
40-
schema_any(schema_any_module.ErrorClass)
41-
schema_any(schema_any_module.DecimalPrimaryKey)
42-
schema_any(schema_any_module.IndexRich)
43-
schema_any(schema_any_module.ThingA)
44-
schema_any(schema_any_module.ThingB)
45-
schema_any(schema_any_module.ThingC)
46-
schema_any(schema_any_module.Parent)
47-
schema_any(schema_any_module.Child)
48-
schema_any(schema_any_module.ComplexParent)
49-
schema_any(schema_any_module.ComplexChild)
50-
schema_any(schema_any_module.SubjectA)
51-
schema_any(schema_any_module.SessionA)
52-
schema_any(schema_any_module.SessionStatusA)
53-
schema_any(schema_any_module.SessionDateA)
54-
schema_any(schema_any_module.Stimulus)
55-
schema_any(schema_any_module.Longblob)
56-
57-
# Add nodes from schema_alter_module
58-
schema_any(Experiment, context=schema_alter_module.LOCALS_ALTER)
59-
schema_any(Parent, context=schema_alter_module.LOCALS_ALTER)
60-
65+
def schema_alter(connection_test, schema_any):
66+
# Overwrite Experiment and Parent nodes
67+
schema_any(Experiment, context=LOCALS_ALTER)
68+
schema_any(Parent, context=LOCALS_ALTER)
6169
yield schema_any
6270
schema_any.drop()
6371

0 commit comments

Comments
 (0)