def commands_discover(request): if request.method == "POST": if len(request.POST.keys()) == 1: command_slug = request.POST.keys()[0] command = get_undiscovered_commands().get(command_slug) if command: Command.objects.get_or_create(slug=command.identifier) return HttpResponseRedirect(reverse('cthulhubot-commands-discover')) return direct_to_template(request, 'cthulhubot/commands_discover.html', { 'commands' : get_undiscovered_commands(), })
def test_discovery_of_unconfigured_packages_finding_configured_and_unconfigured(self): slug = 'cthulhubot-debian-build-debian-package' cmd = get_command(slug)() Command.objects.create(slug=cmd.identifier) unconfigured_slug = 'cthulhubot-django-unit-test-config' commands = get_undiscovered_commands() self.assert_equals(None, commands.get(cmd.identifier)) self.assert_equals(unconfigured_slug, commands.get(unconfigured_slug).identifier)
def test_discovery_of_unconfigured_packages_matches_unconfigured(self): slug = 'cthulhubot-debian-build-debian-package' commands = get_undiscovered_commands() self.assert_equals(slug, commands.get(slug).identifier)
def test_discovery_of_unconfigured_packages_misses_configured_ones(self): cmd = get_command('cthulhubot-debian-build-debian-package')() Command.objects.create(slug=cmd.identifier) commands = get_undiscovered_commands() assert cmd.identifier not in commands