Skip to content

Commit

Permalink
Add an option to run the inst script main() with default args
Browse files Browse the repository at this point in the history
This fixes the test failure when `main()` is imported and run as a
module in `osf_tests/test_elastic_search.py::TestSearchMigration`
by setting `default_args=True` during setup. Running the script via
command line is not affected using `default_args=False`.
  • Loading branch information
cslzchen committed Aug 19, 2019
1 parent 224789b commit 4c5a0ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion osf_tests/test_elastic_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ def tearDownClass(cls):

def setUp(self):
super(TestSearchMigration, self).setUp()
populate_institutions('test')
populate_institutions(default_args=True)
self.es = search.search_engine.CLIENT
search.delete_index(settings.ELASTIC_INDEX)
search.create_index(settings.ELASTIC_INDEX)
Expand Down
10 changes: 7 additions & 3 deletions scripts/populate_institutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ def update_or_create(inst_data):
return inst, True


def main():
def main(default_args=False):

if default_args:
args = parser.parse_args(['--env', 'test', '--all'])
else:
args = parser.parse_args()

args = parser.parse_args()
server_env = args.env
update_ids = args.ids
update_all = args.all
Expand Down Expand Up @@ -1661,4 +1665,4 @@ def main():

if __name__ == '__main__':

main()
main(default_args=False)

0 comments on commit 4c5a0ad

Please sign in to comment.