def test_run(self):
        instance1 = ShoveInstanceFactory.create(hostname='foo', active=True)
        instance2 = ShoveInstanceFactory.create(hostname='bar', active=True)
        command = ScheduledCommandFactory(command='asdf', hostnames='foo,bar')
        command.project.send_command = Mock()

        with patch('captain.projects.models.timezone') as mock_timezone:
            now =  aware_datetime(2014, 1, 1, 1, 1, 1)
            mock_timezone.now.return_value = now
            command.run()

        assert_equal(command.last_run, now)
        command.project.send_command.assert_called_with(None, 'asdf',
                                                        CONTAINS(instance1, instance2))
 def _mock_command(self, *args, **kwargs):
     """
     Create a mock command that wraps a real ScheduledCommand (to trigger AttributeErrors on
     invalid attributes) and which mocks out send_command.
     """
     mock_command = Mock(*args, wraps=ScheduledCommandFactory.create(), **kwargs)
     mock_command.project.send_command = Mock()
     return mock_command