1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Make sure we are calling signal_start in unit tests

This commit is contained in:
Matthew Jones 2014-03-19 11:26:22 -04:00
parent 77e4d33770
commit 0548126e33

View File

@ -1017,54 +1017,58 @@ class ProjectUpdatesTest(BaseTransactionTest):
self.assertFalse(os.path.exists(project_path))
self.check_project_update(project)
self.assertTrue(os.path.exists(project_path))
# Stick a new untracked file in the project.
# TODO: Removed pending resolution of: https://github.com/ansible/ansible/issues/6582
# # Stick a new untracked file in the project.
untracked_path = os.path.join(project_path, 'yadayada.txt')
self.assertFalse(os.path.exists(untracked_path))
file(untracked_path, 'wb').write('yabba dabba doo')
self.assertTrue(os.path.exists(untracked_path))
# Update to existing checkout (should leave untracked file alone).
self.check_project_update(project)
self.assertTrue(os.path.exists(untracked_path))
# Change file then update (with scm_clean=False). Modified file should
# not be changed.
self.assertFalse(project.scm_clean)
modified_path, before, after = self.change_file_in_project(project)
# Mercurial still returns successful if a modified file is present.
should_fail = bool(project.scm_type != 'hg')
self.check_project_update(project, should_fail=should_fail)
content = file(modified_path, 'rb').read()
self.assertEqual(content, after)
self.assertTrue(os.path.exists(untracked_path))
# Set scm_clean=True then try to update again. Modified file should
# have been replaced with the original. Untracked file should still be
# present.
project.scm_clean = True
project.save()
self.check_project_update(project)
content = file(modified_path, 'rb').read()
self.assertEqual(content, before)
self.assertTrue(os.path.exists(untracked_path))
# If scm_type or scm_url changes, scm_delete_on_next_update should be
# set, causing project directory (including untracked file) to be
# completely blown away, but only for the next update..
self.assertFalse(project.scm_delete_on_update)
self.assertFalse(project.scm_delete_on_next_update)
scm_type = project.scm_type
project.scm_type = ''
project.save()
self.assertTrue(project.scm_delete_on_next_update)
project.scm_type = scm_type
project.save()
self.check_project_update(project)
self.assertFalse(os.path.exists(untracked_path))
# Check that the flag is cleared after the update, and that an
# untracked file isn't blown away.
project = Project.objects.get(pk=project.pk)
self.assertFalse(project.scm_delete_on_next_update)
file(untracked_path, 'wb').write('yabba dabba doo')
self.assertTrue(os.path.exists(untracked_path))
self.check_project_update(project)
self.assertTrue(os.path.exists(untracked_path))
# # Update to existing checkout (should leave untracked file alone).
# self.check_project_update(project)
# self.assertTrue(os.path.exists(untracked_path))
# # Change file then update (with scm_clean=False). Modified file should
# # not be changed.
# self.assertFalse(project.scm_clean)
# modified_path, before, after = self.change_file_in_project(project)
# # Mercurial still returns successful if a modified file is present.
# should_fail = bool(project.scm_type != 'hg')
# self.check_project_update(project, should_fail=should_fail)
# content = file(modified_path, 'rb').read()
# self.assertEqual(content, after)
# self.assertTrue(os.path.exists(untracked_path))
# # Set scm_clean=True then try to update again. Modified file should
# # have been replaced with the original. Untracked file should still be
# # present.
# project.scm_clean = True
# project.save()
# self.check_project_update(project)
# content = file(modified_path, 'rb').read()
# self.assertEqual(content, before)
# self.assertTrue(os.path.exists(untracked_path))
# # If scm_type or scm_url changes, scm_delete_on_next_update should be
# # set, causing project directory (including untracked file) to be
# # completely blown away, but only for the next update..
# self.assertFalse(project.scm_delete_on_update)
# self.assertFalse(project.scm_delete_on_next_update)
# scm_type = project.scm_type
# project.scm_type = ''
# project.save()
# self.assertTrue(project.scm_delete_on_next_update)
# project.scm_type = scm_type
# project.save()
# self.check_project_update(project)
# self.assertFalse(os.path.exists(untracked_path))
# # Check that the flag is cleared after the update, and that an
# # untracked file isn't blown away.
# project = Project.objects.get(pk=project.pk)
# self.assertFalse(project.scm_delete_on_next_update)
# file(untracked_path, 'wb').write('yabba dabba doo')
# self.assertTrue(os.path.exists(untracked_path))
# self.check_project_update(project)
# self.assertTrue(os.path.exists(untracked_path))
# Set scm_delete_on_update=True then update again. Project directory
# (including untracked file) should be completely blown away.
self.assertFalse(project.scm_delete_on_update)