88import  datajoint  as  dj 
99from  .schema_external  import  stores_config 
1010from  .schema_external  import  SimpleRemote 
11- current_location  =  dj .config ['stores' ]['share' ]['location' ]
11+ current_location_s3  =  dj .config ['stores' ]['share' ]['location' ]
12+ current_location_local  =  dj .config ['stores' ]['local' ]['location' ]
1213
1314
1415def  setUp (self ):
1516    dj .config ['stores' ] =  stores_config 
1617
1718
1819def  tearDown (self ):
19-     dj .config ['stores' ]['share' ]['location' ] =  current_location 
20+     dj .config ['stores' ]['share' ]['location' ] =  current_location_s3 
21+     dj .config ['stores' ]['local' ]['location' ] =  current_location_local 
2022
2123
2224def  test_external_put ():
@@ -41,38 +43,63 @@ def test_external_put():
4143    assert_array_equal (input_ , output_ )
4244
4345
44- def  test_leading_slash ( ):
46+ def  test_s3_leading_slash ( index = 100 ,  store = 'share' ):
4547    """ 
46-     external storage configured with leading slash 
48+     s3  external storage configured with leading slash 
4749    """ 
4850    value  =  np .array ([1 , 2 , 3 ])
4951
50-     id  =  100 
51-     dj .config ['stores' ]['share' ]['location' ] =  'leading/slash/test' 
52+     id  =  index 
53+     dj .config ['stores' ][store ]['location' ] =  'leading/slash/test' 
5254    SimpleRemote .insert ([{'simple' : id , 'item' : value }])
5355    assert_true (np .array_equal (
5456        value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
5557
56-     id  =  101 
57-     dj .config ['stores' ]['share' ]['location' ] =  '/leading/slash/test' 
58+     id  =  index   +   1 
59+     dj .config ['stores' ][store ]['location' ] =  '/leading/slash/test' 
5860    SimpleRemote .insert ([{'simple' : id , 'item' : value }])
5961    assert_true (np .array_equal (
6062        value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
6163
62-     id  =  102 
63-     dj .config ['stores' ]['share' ]['location' ] =  'leading\\ slash\\ test' 
64+     id  =  index   +   2 
65+     dj .config ['stores' ][store ]['location' ] =  'leading\\ slash\\ test' 
6466    SimpleRemote .insert ([{'simple' : id , 'item' : value }])
6567    assert_true (np .array_equal (
6668        value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
6769
68-     id  =  103 
69-     dj .config ['stores' ]['share' ]['location' ] =  'f:\\ leading\\ slash\\ test' 
70+     id  =  index   +   3 
71+     dj .config ['stores' ][store ]['location' ] =  'f:\\ leading\\ slash\\ test' 
7072    SimpleRemote .insert ([{'simple' : id , 'item' : value }])
7173    assert_true (np .array_equal (
7274        value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
7375
74-     id  =  104 
75-     dj .config ['stores' ]['share' ]['location' ] =  'f:\\ leading/slash\\ test' 
76+     id  =  index   +   4 
77+     dj .config ['stores' ][store ]['location' ] =  'f:\\ leading/slash\\ test' 
7678    SimpleRemote .insert ([{'simple' : id , 'item' : value }])
7779    assert_true (np .array_equal (
7880        value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
81+ 
82+     id  =  index  +  5 
83+     dj .config ['stores' ][store ]['location' ] =  '/' 
84+     SimpleRemote .insert ([{'simple' : id , 'item' : value }])
85+     assert_true (np .array_equal (
86+         value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
87+ 
88+     id  =  index  +  6 
89+     dj .config ['stores' ][store ]['location' ] =  'C:\\ ' 
90+     SimpleRemote .insert ([{'simple' : id , 'item' : value }])
91+     assert_true (np .array_equal (
92+         value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
93+ 
94+     id  =  index  +  7 
95+     dj .config ['stores' ][store ]['location' ] =  '' 
96+     SimpleRemote .insert ([{'simple' : id , 'item' : value }])
97+     assert_true (np .array_equal (
98+         value , (SimpleRemote  &  'simple={}' .format (id )).fetch1 ('item' )))
99+ 
100+ 
101+ def  test_file_leading_slash ():
102+     """ 
103+     file external storage configured with leading slash 
104+     """ 
105+     test_s3_leading_slash (index = 200 , store = 'local' )
0 commit comments