def test_get_command_to_run_the_current_method_when_manage_py_not_found( self): current_dir = '/tmp/bad_project_no_files/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() with self.assertRaises(sut.NotDjango): sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer)
def test_get_command_to_run_the_current_method_when_multiple_apps_are_listed_and_a_valid_app_name_is_not_in_config_file( self): current_dir = "/tmp/bad_project_multiple_invalid_apps/example_app1/tests/test_file.py" current_line = 17 current_buffer = self.build_buffer_helper() with self.assertRaises(sut.NoVimDjango): sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer)
def test_get_command_to_run_the_current_method_when_config_not_properly_formated( self): current_dir = '/tmp/bad_project_no_app/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() with self.assertRaises(sut.NoVimDjango): sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer)
def test_get_command_to_run_the_current_method_when_multiple_apps_are_listed_and_a_valid_app_name_is_in_config_file(self): current_dir = "/tmp/project_multiple_apps/example_app1/tests/test_file.py" current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_multiple_apps/manage.py test example_app1.tests.test_file:Example1.dummy2" command_returned = sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer) self.assertEqual(command_returned, expected_return_value)
def test_get_command_to_run_the_current_method_when_multiple_apps_are_listed_and_a_valid_app_name_is_not_in_config_file(self): current_dir = "/tmp/bad_project_multiple_invalid_apps/example_app1/tests/test_file.py" current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = ".vim-django does not exist" command_returned = sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer) self.assertEqual(command_returned, expected_return_value)
def test_get_command_to_run_current_method_when_tests_are_in_a_nested_directory(self): current_dir = "/tmp/project_nested_test_dirs/example_app1/tests/nested1/test_nested_file.py" current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_nested_test_dirs/manage.py test example_app1.tests.nested1.test_nested_file:Example1.dummy2" command_returned = sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer) self.assertEqual(command_returned, expected_return_value)
def test_get_command_to_run_current_method_writes_command_to_cache_file_when_successfully_called(self): current_dir = '/tmp/project_app_only/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() command_to_run = sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer) last_command = self.get_cached_command() self.assertEqual(command_to_run, last_command)
def test_get_command_to_run_current_method_when_app_name_has_dots(self): current_dir = "/tmp/project_with_dots/example.app.something/tests/test_dot_file.py" current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_with_dots/manage.py test example.app.something.tests.test_dot_file:Example1.dummy2" command_returned = sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer) self.assertEqual(command_returned, expected_return_value)
def test_get_command_to_run_current_method_when_app_name_has_dots(self): current_dir = "/tmp/project_with_dots/example.app.something/tests/test_dot_file.py" current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_with_dots/manage.py test example.app.something.tests.test_dot_file:Example1.dummy2" command_returned = sut.get_command_to_run_the_current_method( current_dir, current_line, current_buffer) self.assertEqual(command_returned, expected_return_value)
def test_get_command_to_run_the_current_method_when_multiple_apps_are_listed_and_a_valid_app_name_is_in_config_file( self): current_dir = "/tmp/project_multiple_apps/example_app1/tests/test_file.py" current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_multiple_apps/manage.py test example_app1.tests.test_file:Example1.dummy2" command_returned = sut.get_command_to_run_the_current_method( current_dir, current_line, current_buffer) self.assertEqual(command_returned, expected_return_value)
def test_get_command_to_run_current_method_when_tests_are_in_a_nested_directory( self): current_dir = "/tmp/project_nested_test_dirs/example_app1/tests/nested1/test_nested_file.py" current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_nested_test_dirs/manage.py test example_app1.tests.nested1.test_nested_file:Example1.dummy2" command_returned = sut.get_command_to_run_the_current_method( current_dir, current_line, current_buffer) self.assertEqual(command_returned, expected_return_value)
def test_get_command_to_run_current_method_writes_command_to_cache_file_when_successfully_called( self): current_dir = '/tmp/project_app_only/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() command_to_run = sut.get_command_to_run_the_current_method( current_dir, current_line, current_buffer) last_command = self.get_cached_command() self.assertEqual(command_to_run, last_command)
def test_get_command_to_run_current_method_when_current_line_occurs_in_file_more_than_once( self): current_dir = '/tmp/project_app_name_and_env/example_app1/tests/test_file.py' current_line = 50 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_app_name_and_env/manage.py test test example_app1.tests.test_file:Example3.double_dummy" self.assertEqual( expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_with_manage_py_app_name_and_env_specified( self): current_dir = '/tmp/project_app_name_and_env/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_app_name_and_env/manage.py test test example_app1.tests.test_file:Example1.dummy2" self.assertEqual( expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_with_manage_py_app_name_but_no_env_specified(self): current_dir = '/tmp/good_dirs_app_only/Level1/Level2/Level3' current_line = " print('This is a testD')\n" current_buffer = self.build_buffer_helper() self.assertEqual(":!python /tmp/good_dirs_app_only/manage.py test example_app.Example1.dummy2", sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_when_config_not_present(self): current_dir = '/tmp/bad_dirs_no_app_specified/Level1/Level2/Level3' current_line = " print('This is a testD')\n" current_buffer = self.build_buffer_helper() expected_return_value = ".vim-django file does not exist or is improperly formated. ':help run-django-tests'" self.assertEqual(expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_current_method_when_current_line_occurs_in_file_more_than_once(self): current_dir = '/tmp/project_app_name_and_env/example_app1/tests/test_file.py' current_line = 50 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_app_name_and_env/manage.py test test example_app1.tests.test_file:Example3.double_dummy" self.assertEqual(expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_when_manage_py_not_found(self): current_dir = '/tmp/bad_dirs_no_files/Level1/Level2/Level3' current_line = " print('This is a testD')\n" current_buffer = self.build_buffer_helper() expected_return_value = "Are you sure this is a Django project?" self.assertEqual(expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_when_multiple_apps_are_listed_and_a_valid_app_name_is_not_in_config_file(self): current_dir = "/tmp/bad_project_multiple_invalid_apps/example_app1/tests/test_file.py" current_line = 17 current_buffer = self.build_buffer_helper() with self.assertRaises(sut.NoVimDjango): sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer)
def test_get_command_to_run_the_current_method_when_config_not_present(self): current_dir = '/tmp/bad_project_no_app/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = ".vim-django does not exist" self.assertEqual(expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_when_manage_py_not_found(self): current_dir = '/tmp/bad_project_no_files/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() with self.assertRaises(sut.NotDjango): sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer)
def test_get_command_to_run_the_current_method_when_config_not_properly_formated(self): current_dir = '/tmp/bad_project_no_app/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() with self.assertRaises(sut.NoVimDjango): sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer)
def test_get_command_to_run_the_current_method_with_manage_py_app_name_and_env_specified(self): current_dir = '/tmp/project_app_name_and_env/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "/tmp/project_app_name_and_env/manage.py test test example_app1.tests.test_file:Example1.dummy2" self.assertEqual(expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_when_manage_py_not_found(self): current_dir = '/tmp/bad_project_no_files/example_app1/tests/test_file.py' current_line = 17 current_buffer = self.build_buffer_helper() expected_return_value = "Not Django" self.assertEqual(expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))
def test_get_command_to_run_the_current_method_with_manage_py_app_name_and_env_specified(self): current_dir = '/tmp/good_dirs_app_name_and_env_defined/Level1/Level2/Level3' current_line = " print('This is a testD')\n" current_buffer = self.build_buffer_helper() expected_return_value = ":!python /tmp/good_dirs_app_name_and_env_defined/manage.py test test example_app.Example1.dummy2" self.assertEqual(expected_return_value, sut.get_command_to_run_the_current_method(current_dir, current_line, current_buffer))