Skip to content

Commit

Permalink
Make refresh rebuild the file list
Browse files Browse the repository at this point in the history
Closes #183
  • Loading branch information
mwcraig committed Jan 21, 2015
1 parent 9c384bb commit f567d31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions msumastro/image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def refresh(self):
Refresh the collection by re-reading headers.
"""
keywords = '*' if self._all_keywords else self.keywords
# Re-load list of files
self._files = self._fits_files_in_directory()
self._summary_info = self._fits_summary(header_keywords=keywords)

def _dict_from_fits_header(self, file_name, input_summary=None,
Expand Down
14 changes: 13 additions & 1 deletion msumastro/tests/test_image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def test_header_with_long_history_roundtrips_to_disk(self, triage_setup):
table_disk = Table.read('test_table.txt', format='ascii.csv')
assert len(table_disk) == len(ic.summary_info)

def test_refresh_method(self, triage_setup):
def test_refresh_method_sees_added_keywords(self, triage_setup):
ic = tff.ImageFileCollection(triage_setup.test_dir, keywords='*')
# Add a keyword I know isn't already in the header to each file.
not_in_header = 'BARKARK'
Expand All @@ -520,3 +520,15 @@ def test_refresh_method(self, triage_setup):
# After refreshing the odd keyword should be present.
print(ic.keywords)
assert not_in_header.lower() in ic.summary_info.colnames

def test_refresh_method_sees_added_files(self, triage_setup):
ic = tff.ImageFileCollection(triage_setup.test_dir, keywords='*')
# Compressed files don't get copied. Not sure why...
original_len = len(ic.summary_info) - triage_setup.n_test['compressed']
# Generate additional files in this directory
for h in ic.headers(save_with_name="_foo"):
pass
ic.refresh()
new_len = len(ic.summary_info) - triage_setup.n_test['compressed']
print(ic.summary_info['file'])
assert new_len == 2 * original_len

0 comments on commit f567d31

Please sign in to comment.