|
1 |
| -from nose.tools import assert_true, assert_list_equal |
2 | 1 | from numpy.testing import assert_almost_equal
|
3 | 2 | import datajoint as dj
|
4 |
| -from . import schema_external as modu |
| 3 | +from . import schema_external |
5 | 4 |
|
6 | 5 |
|
7 |
| -def setUp(self): |
8 |
| - dj.config["stores"] = modu.stores_config |
| 6 | +def test_heading(schema_ext, mock_stores): |
| 7 | + heading = schema_external.Simple().heading |
| 8 | + assert "item" in heading |
| 9 | + assert heading["item"].is_external |
9 | 10 |
|
10 | 11 |
|
11 |
| -def test_heading(): |
12 |
| - heading = modu.Simple().heading |
13 |
| - assert_true("item" in heading) |
14 |
| - assert_true(heading["item"].is_external) |
15 |
| - |
16 |
| - |
17 |
| -def test_insert_and_fetch(): |
| 12 | +def test_insert_and_fetch(schema_ext, mock_stores, mock_cache): |
18 | 13 | original_list = [1, 3, 8]
|
19 |
| - modu.Simple().insert1(dict(simple=1, item=original_list)) |
| 14 | + schema_external.Simple().insert1(dict(simple=1, item=original_list)) |
20 | 15 | # test fetch
|
21 |
| - q = (modu.Simple() & {"simple": 1}).fetch("item")[0] |
22 |
| - assert_list_equal(list(q), original_list) |
| 16 | + q = (schema_external.Simple() & {"simple": 1}).fetch("item")[0] |
| 17 | + assert list(q) == original_list |
23 | 18 | # test fetch1 as a tuple
|
24 |
| - q = (modu.Simple() & {"simple": 1}).fetch1("item") |
25 |
| - assert_list_equal(list(q), original_list) |
| 19 | + q = (schema_external.Simple() & {"simple": 1}).fetch1("item") |
| 20 | + assert list(q) == original_list |
26 | 21 | # test fetch1 as a dict
|
27 |
| - q = (modu.Simple() & {"simple": 1}).fetch1() |
28 |
| - assert_list_equal(list(q["item"]), original_list) |
| 22 | + q = (schema_external.Simple() & {"simple": 1}).fetch1() |
| 23 | + assert list(q["item"]) == original_list |
29 | 24 | # test without cache
|
30 | 25 | previous_cache = dj.config["cache"]
|
31 | 26 | dj.config["cache"] = None
|
32 |
| - q = (modu.Simple() & {"simple": 1}).fetch1() |
33 |
| - assert_list_equal(list(q["item"]), original_list) |
| 27 | + q = (schema_external.Simple() & {"simple": 1}).fetch1() |
| 28 | + assert list(q["item"]) == original_list |
34 | 29 | # test with cache
|
35 | 30 | dj.config["cache"] = previous_cache
|
36 |
| - q = (modu.Simple() & {"simple": 1}).fetch1() |
37 |
| - assert_list_equal(list(q["item"]), original_list) |
| 31 | + q = (schema_external.Simple() & {"simple": 1}).fetch1() |
| 32 | + assert list(q["item"]) == original_list |
38 | 33 |
|
39 | 34 |
|
40 |
| -def test_populate(): |
41 |
| - image = modu.Image() |
| 35 | +def test_populate(schema_ext, mock_stores): |
| 36 | + image = schema_external.Image() |
42 | 37 | image.populate()
|
43 | 38 | remaining, total = image.progress()
|
44 |
| - assert_true(total == len(modu.Dimension() * modu.Seed()) and remaining == 0) |
| 39 | + assert total == len(schema_external.Dimension() * schema_external.Seed()) and remaining == 0 |
45 | 40 | for img, neg, dimensions in zip(
|
46 |
| - *(image * modu.Dimension()).fetch("img", "neg", "dimensions") |
| 41 | + *(image * schema_external.Dimension()).fetch("img", "neg", "dimensions") |
47 | 42 | ):
|
48 |
| - assert_list_equal(list(img.shape), list(dimensions)) |
| 43 | + assert list(img.shape) == list(dimensions) |
49 | 44 | assert_almost_equal(img, -neg)
|
50 | 45 | image.delete()
|
51 |
| - dj.errors._switch_filepath_types(True) |
52 | 46 | for external_table in image.external.values():
|
53 | 47 | external_table.delete(display_progress=False, delete_external_files=True)
|
54 |
| - dj.errors._switch_filepath_types(False) |
0 commit comments