Exemplo n.º 1
0
    def test_clean_command(self):
        f = TranslationForm({"command": ""})
        self.assertFalse(f.is_valid())
        self.assertEqual(f.errors["command"], ["This field is required."])

        f = TranslationForm({"command": "arch commit", "vcs": "git"})
        self.assertFalse(f.is_valid())
        self.assertEqual(f.errors["command"], ["Command must start with a valid VCS (bzr, git, hg, svn)."])

        f = TranslationForm({"command": "svn commit", "vcs": "git"})
        self.assertTrue(f.is_valid())
Exemplo n.º 2
0
def home(request):
    form = TranslationForm(request.GET or None)
    results = None
    if form.is_valid():
        results = form.translate()
        request.session["last_translation"] = form.get_data()
    return render_to_response("translator/home.html", {
        "form": form,
        "results": results,
    }, context_instance=RequestContext(request))