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))