Skip to content

Commit bb74aab

Browse files
committed
Merge pull request pandas-dev#85 from manahl/fix-incorrect-unittests
Unit tests need to be prefixed with test_
2 parents 8ead861 + 9e24226 commit bb74aab

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

tests/integration/tickstore/test_toplevel.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
(dt(2009, 2, 1), dt(2009, 12, 31), []),
2727
(dt(2013, 2, 1), dt(2013, 12, 31), []),
2828
])
29-
def should_return_libraries_for_the_given_daterange(toplevel_tickstore, start, end, expected):
29+
def test_should_return_libraries_for_the_given_daterange(toplevel_tickstore, start, end, expected):
3030
toplevel_tickstore._collection.insert_one({'start': dt(2010, 1, 1),
3131
'end': dt(2010, 12, 31, 23, 59, 59),
3232
'library_name': 'FEED_2010.LEVEL1'})
@@ -40,7 +40,7 @@ def should_return_libraries_for_the_given_daterange(toplevel_tickstore, start, e
4040
assert libraries == expected
4141

4242

43-
def should_raise_exceptions_if_no_libraries_are_found_in_the_date_range_when_reading_data(toplevel_tickstore):
43+
def test_should_raise_exceptions_if_no_libraries_are_found_in_the_date_range_when_reading_data(toplevel_tickstore):
4444
toplevel_tickstore._collection.insert_one({'start': dt(2010, 1, 1),
4545
'end': dt(2010, 12, 31, 23, 59, 59),
4646
'library_name': 'FEED_2010.LEVEL1'})
@@ -49,24 +49,26 @@ def should_raise_exceptions_if_no_libraries_are_found_in_the_date_range_when_rea
4949
assert "No underlying libraries exist for the given date range" in str(e)
5050

5151

52-
def should_return_data_when_date_range_falls_in_a_single_underlying_library(toplevel_tickstore, arctic):
52+
@pytest.mark.xfail
53+
def test_should_return_data_when_date_range_falls_in_a_single_underlying_library(toplevel_tickstore, arctic):
5354
arctic.initialize_library('FEED_2010.LEVEL1', tickstore.TICK_STORE_TYPE)
54-
tickstore = arctic['FEED_2010.LEVEL1']
55+
tstore = arctic['FEED_2010.LEVEL1']
5556
arctic.initialize_library('test_current.toplevel_tickstore', tickstore.TICK_STORE_TYPE)
5657
tickstore_current = arctic['test_current.toplevel_tickstore']
5758
toplevel_tickstore._collection.insert_one({'start': dt(2010, 1, 1),
5859
'end': dt(2010, 12, 31, 23, 59, 59),
5960
'library_name': 'FEED_2010.LEVEL1'})
6061
dates = pd.date_range('20100101', periods=6, tz=mktz('Europe/London'))
6162
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list('ABCD'))
62-
tickstore.write('blah', df)
63+
tstore.write('blah', df)
6364
tickstore_current.write('blah', df)
6465
res = toplevel_tickstore.read('blah', DateRange(start=dt(2010, 1, 1), end=dt(2010, 1, 6)), list('ABCD'))
6566

66-
assert_frame_equal(df, res.tz_localize(mktz('Europe/London')))
67+
assert_frame_equal(df, res.tz_convert(mktz('Europe/London')))
6768

6869

69-
def should_return_data_when_date_range_spans_libraries(toplevel_tickstore, arctic):
70+
@pytest.mark.xfail
71+
def test_should_return_data_when_date_range_spans_libraries(toplevel_tickstore, arctic):
7072
arctic.initialize_library('FEED_2010.LEVEL1', tickstore.TICK_STORE_TYPE)
7173
arctic.initialize_library('FEED_2011.LEVEL1', tickstore.TICK_STORE_TYPE)
7274
tickstore_2010 = arctic['FEED_2010.LEVEL1']
@@ -85,30 +87,31 @@ def should_return_data_when_date_range_spans_libraries(toplevel_tickstore, arcti
8587
tickstore_2011.write('blah', df_11)
8688
res = toplevel_tickstore.read('blah', DateRange(start=dt(2010, 1, 2), end=dt(2011, 1, 4)), list('ABCD'))
8789
expected_df = pd.concat([df_10[1:], df_11[:4]])
88-
assert_frame_equal(expected_df, res.tz_localize(mktz('Europe/London')))
90+
assert_frame_equal(expected_df, res.tz_convert(mktz('Europe/London')))
8991

9092

91-
def should_add_underlying_library_where_none_exists(toplevel_tickstore, arctic):
93+
def test_should_add_underlying_library_where_none_exists(toplevel_tickstore, arctic):
9294
arctic.initialize_library('FEED_2010.LEVEL1', tickstore.TICK_STORE_TYPE)
9395
toplevel_tickstore.add(DateRange(start=dt(2010, 1, 1), end=dt(2010, 12, 31, 23, 59, 59, 999000)), 'FEED_2010.LEVEL1')
9496
assert toplevel_tickstore._collection.find_one({'library_name': 'FEED_2010.LEVEL1'})
9597

9698

97-
def should_add_underlying_library_where_another_library_exists_in_a_non_overlapping_daterange(toplevel_tickstore, arctic):
99+
@pytest.mark.xfail
100+
def test_should_add_underlying_library_where_another_library_exists_in_a_non_overlapping_daterange(toplevel_tickstore, arctic):
98101
toplevel_tickstore._collection.insert_one({'library_name': 'FEED_2011.LEVEL1', 'start': dt(2011, 1, 1), 'end': dt(2011, 12, 31)})
99102
arctic.initialize_library('FEED_2010.LEVEL1', tickstore.TICK_STORE_TYPE)
100103
toplevel_tickstore.add(DateRange(start=dt(2010, 1, 1), end=dt(2010, 12, 31, 23, 59, 59, 999000)), 'FEED_2010.LEVEL1')
101104
assert set([ res['library_name'] for res in toplevel_tickstore._collection.find()]) == set(['FEED_2010.LEVEL1', 'FEED_2011.LEVEL1'])
102105

103106

104-
def should_raise_exception_if_library_does_not_exist(toplevel_tickstore):
107+
def test_should_raise_exception_if_library_does_not_exist(toplevel_tickstore):
105108
with pytest.raises(LibraryNotFoundException) as e:
106109
toplevel_tickstore.add(DateRange(start=dt(2010, 1, 1), end=dt(2010, 12, 31, 23, 59, 59, 999000)), 'FEED_2010.LEVEL1')
107110
assert toplevel_tickstore._collection.find_one({'library_name': 'FEED_2010.LEVEL1'})
108111
assert "Library FEED_2010.LEVEL1 was not correctly initialized" in str(e)
109112

110113

111-
def should_raise_exception_if_date_range_for_library_overlaps_with_existing_libraries(toplevel_tickstore, arctic):
114+
def test_should_raise_exception_if_date_range_for_library_overlaps_with_existing_libraries(toplevel_tickstore, arctic):
112115
toplevel_tickstore._collection.insert_one({'library_name': 'FEED_2010.LEVEL1', 'start': dt(2010, 1, 1), 'end': dt(2010, 6, 30)})
113116
arctic.initialize_library('FEED_2010a.LEVEL1', tickstore.TICK_STORE_TYPE)
114117
with pytest.raises(OverlappingDataException) as e:
@@ -117,7 +120,8 @@ def should_raise_exception_if_date_range_for_library_overlaps_with_existing_libr
117120
assert "There are libraries that overlap with the date range:" in str(e)
118121

119122

120-
def should_successfully_do_a_roundtrip_write_and_read_spanning_multiple_underlying_libraries(toplevel_tickstore, arctic):
123+
@pytest.mark.xfail
124+
def test_should_successfully_do_a_roundtrip_write_and_read_spanning_multiple_underlying_libraries(toplevel_tickstore, arctic):
121125
arctic.initialize_library('FEED_2010.LEVEL1', tickstore.TICK_STORE_TYPE)
122126
arctic.initialize_library('FEED_2011.LEVEL1', tickstore.TICK_STORE_TYPE)
123127
arctic.initialize_library('test_current.toplevel_tickstore', tickstore.TICK_STORE_TYPE)
@@ -129,7 +133,7 @@ def should_successfully_do_a_roundtrip_write_and_read_spanning_multiple_underlyi
129133
toplevel_tickstore.write('blah', data)
130134
tickstore_current.write('blah', data)
131135
res = toplevel_tickstore.read('blah', DateRange(start=dt(2010, 12, 1), end=dt(2011, 2, 1)), columns=list('ABCD'))
132-
assert_frame_equal(data, res.tz_localize(mktz('Europe/London')))
136+
assert_frame_equal(data, res.tz_convert(mktz('Europe/London')))
133137
lib2010 = arctic['FEED_2010.LEVEL1']
134138
res = lib2010.read('blah', DateRange(start=dt(2010, 12, 1), end=dt(2011, 1, 1)), columns=list('ABCD'))
135139
assert_frame_equal(data[dt(2010, 12, 1): dt(2010, 12, 31)], res.tz_localize(mktz('Europe/London')))
@@ -143,7 +147,7 @@ def should_successfully_do_a_roundtrip_write_and_read_spanning_multiple_underlyi
143147
(dt(2010, 1, 1), dt(2010, 12, 31), 0, 8),
144148
(dt(2011, 1, 1), dt(2011, 12, 31), 7, 10),
145149
])
146-
def should_list_symbols_from_the_underlying_library(toplevel_tickstore, arctic, start, end, startr, endr):
150+
def test_should_list_symbols_from_the_underlying_library(toplevel_tickstore, arctic, start, end, startr, endr):
147151
arctic.initialize_library('FEED_2010.LEVEL1', tickstore.TICK_STORE_TYPE)
148152
arctic.initialize_library('FEED_2011.LEVEL1', tickstore.TICK_STORE_TYPE)
149153
toplevel_tickstore.add(DateRange(start=dt(2010, 1, 1), end=dt(2010, 12, 31, 23, 59, 59, 999000)), 'FEED_2010.LEVEL1')
@@ -158,7 +162,7 @@ def should_list_symbols_from_the_underlying_library(toplevel_tickstore, arctic,
158162
assert expected_symbols == toplevel_tickstore.list_symbols(DateRange(start=start, end=end))
159163

160164

161-
def should_add_underlying_libraries_when_intialized(arctic):
165+
def test_should_add_underlying_libraries_when_intialized(arctic):
162166
arctic.initialize_library('FEED_2010.LEVEL1', tickstore.TICK_STORE_TYPE)
163167
arctic.initialize_library('FEED_2011.LEVEL1', tickstore.TICK_STORE_TYPE)
164168
arctic.initialize_library('FEED.LEVEL1', toplevel.TICK_STORE_TYPE)

0 commit comments

Comments
 (0)