Skip to content

Commit e2c0d30

Browse files
committed
Define schema_alter in test module
Per @A-Baji suggestion
1 parent 6935e87 commit e2c0d30

File tree

2 files changed

+60
-64
lines changed

2 files changed

+60
-64
lines changed

tests/schema_alter.py

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

tests/test_alter.py

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,66 @@
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 = {
58+
"Experiment": Experiment,
59+
"Parent": Parent
60+
}
761
COMBINED_CONTEXT = {
862
**schema_any_module.LOCALS_ANY,
9-
**schema_alter_module.LOCALS_ALTER,
63+
**LOCALS_ALTER,
1064
}
1165

1266

@@ -54,9 +108,9 @@ def schema_alter(connection_test):
54108
schema_any(schema_any_module.Stimulus)
55109
schema_any(schema_any_module.Longblob)
56110

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)
111+
# Overwrite Experiment and Parent nodes
112+
schema_any(Experiment, context=LOCALS_ALTER)
113+
schema_any(Parent, context=LOCALS_ALTER)
60114

61115
yield schema_any
62116
schema_any.drop()

0 commit comments

Comments
 (0)