Exemple #1
0
    def test_detects_name_clash_on_name_change(self):
        # A template name may not already be used.
        existing_name = self.factory.getUniqueString()
        existing_potemplate = self.factory.makePOTemplate(name=existing_name)
        series = existing_potemplate.productseries
        potemplate = self.factory.makePOTemplate(productseries=series)

        view = POTemplateEditView(potemplate, LaunchpadTestRequest())
        data = self._makeData(potemplate, name=existing_name)
        view.validate(data)
        self.assertEqual([u'Name is already in use.'], view.errors)
    def test_detects_domain_clash_on_domain_change(self):
        # A translation domain may not already be used.
        existing_domain = self.factory.getUniqueString()
        existing_potemplate = self.factory.makePOTemplate(translation_domain=existing_domain)
        series = existing_potemplate.productseries
        potemplate = self.factory.makePOTemplate(productseries=series)

        view = POTemplateEditView(potemplate, LaunchpadTestRequest())
        data = self._makeData(potemplate, translation_domain=existing_domain)
        view.validate(data)
        self.assertEqual([u"Domain is already in use."], view.errors)
    def test_detects_name_clash_on_name_change(self):
        # A template name may not already be used.
        existing_name = self.factory.getUniqueString()
        existing_potemplate = self.factory.makePOTemplate(name=existing_name)
        series = existing_potemplate.productseries
        potemplate = self.factory.makePOTemplate(productseries=series)

        view = POTemplateEditView(potemplate, LaunchpadTestRequest())
        data = self._makeData(potemplate, name=existing_name)
        view.validate(data)
        self.assertEqual([u"Name is already in use."], view.errors)
    def test_detects_name_clash_on_sourcepackage_change(self):
        # Detect changing to a source package that already has a template of
        # the same name.
        sourcepackage = self.factory.makeSourcePackage()
        existing_potemplate = self.factory.makePOTemplate(sourcepackage=sourcepackage)
        potemplate = self.factory.makePOTemplate(distroseries=sourcepackage.distroseries, name=existing_potemplate.name)

        view = POTemplateEditView(potemplate, LaunchpadTestRequest())
        data = self._makeData(potemplate, sourcepackagename=sourcepackage.sourcepackagename)
        view.validate(data)
        self.assertEqual([u"Source package already has a template with that same name."], view.errors)
Exemple #5
0
    def test_detects_domain_clash_on_domain_change(self):
        # A translation domain may not already be used.
        existing_domain = self.factory.getUniqueString()
        existing_potemplate = self.factory.makePOTemplate(
            translation_domain=existing_domain)
        series = existing_potemplate.productseries
        potemplate = self.factory.makePOTemplate(productseries=series)

        view = POTemplateEditView(potemplate, LaunchpadTestRequest())
        data = self._makeData(potemplate, translation_domain=existing_domain)
        view.validate(data)
        self.assertEqual([u'Domain is already in use.'], view.errors)
Exemple #6
0
 def test_detects_invalid_names(self):
     # A template name must be satisfying the valid_name constraint.
     invalid_name = 'name!'
     potemplate = self.factory.makePOTemplate()
     data = self._makeData(potemplate, name=invalid_name)
     view = POTemplateEditView(potemplate, LaunchpadTestRequest())
     view.validate(data)
     self.assertEqual([
         html_escape(
             u'Template name can only start with lowercase letters a-z '
             u'or digits 0-9, and other than those characters, can only '
             u'contain "-", "+" and "." characters.')
     ], view.errors)
Exemple #7
0
    def test_detects_name_clash_on_sourcepackage_change(self):
        # Detect changing to a source package that already has a template of
        # the same name.
        sourcepackage = self.factory.makeSourcePackage()
        existing_potemplate = self.factory.makePOTemplate(
            sourcepackage=sourcepackage)
        potemplate = self.factory.makePOTemplate(
            distroseries=sourcepackage.distroseries,
            name=existing_potemplate.name)

        view = POTemplateEditView(potemplate, LaunchpadTestRequest())
        data = self._makeData(
            potemplate, sourcepackagename=sourcepackage.sourcepackagename)
        view.validate(data)
        self.assertEqual(
            [u'Source package already has a template with that same name.'],
            view.errors)
 def test_detects_invalid_names(self):
     # A template name must be satisfying the valid_name constraint.
     invalid_name = "name!"
     potemplate = self.factory.makePOTemplate()
     data = self._makeData(potemplate, name=invalid_name)
     view = POTemplateEditView(potemplate, LaunchpadTestRequest())
     view.validate(data)
     self.assertEqual(
         [
             html_escape(
                 u"Template name can only start with lowercase letters a-z "
                 u"or digits 0-9, and other than those characters, can only "
                 u'contain "-", "+" and "." characters.'
             )
         ],
         view.errors,
     )
Exemple #9
0
 def test_field_names_productseries(self):
     # A product series template has one set of field names that include
     # the template name.
     potemplate = self.factory.makePOTemplate()
     view = POTemplateEditView(potemplate, LaunchpadTestRequest())
     self.assertContentEqual([
         'name', 'translation_domain', 'description', 'priority', 'path',
         'iscurrent', 'owner'
     ], view.field_names)
Exemple #10
0
 def test_field_names_sourcepackage(self):
     # A sourcepackage template has two more fields compared to the
     # product series templates.
     sourcepackage = self.factory.makeSourcePackage()
     potemplate = self.factory.makePOTemplate(
         distroseries=sourcepackage.distroseries,
         sourcepackagename=sourcepackage.sourcepackagename)
     view = POTemplateEditView(potemplate, LaunchpadTestRequest())
     self.assertContentEqual([
         'name', 'translation_domain', 'description', 'priority', 'path',
         'iscurrent', 'sourcepackagename', 'languagepack'
     ], view.field_names)