|
1 | 1 | import pytest |
2 | 2 | import re |
3 | 3 | 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 |
6 | 5 |
|
| 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 | +} |
7 | 61 | COMBINED_CONTEXT = { |
8 | 62 | **schema_any_module.LOCALS_ANY, |
9 | | - **schema_alter_module.LOCALS_ALTER, |
| 63 | + **LOCALS_ALTER, |
10 | 64 | } |
11 | 65 |
|
12 | 66 |
|
@@ -54,9 +108,9 @@ def schema_alter(connection_test): |
54 | 108 | schema_any(schema_any_module.Stimulus) |
55 | 109 | schema_any(schema_any_module.Longblob) |
56 | 110 |
|
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) |
60 | 114 |
|
61 | 115 | yield schema_any |
62 | 116 | schema_any.drop() |
|
0 commit comments