Ejemplo n.º 1
0
    def test_weird_list_troubleshooting_info(self):
        """Test the corner case in which 'modifiedPReferences' is in a
        list in troubleshooting data. This is weird, but caused a bug."""
        q = QuestionFactory()
        q.add_metadata(troubleshooting='["modifiedPreferences"]')

        # This case should not raise an error.
        response = get(self.client, "questions.details", args=[q.id])
        eq_(200, response.status_code)
Ejemplo n.º 2
0
    def test_weird_list_troubleshooting_info(self):
        """Test the corner case in which 'modifiedPReferences' is in a
        list in troubleshooting data. This is weird, but caused a bug."""
        q = QuestionFactory()
        q.add_metadata(troubleshooting='["modifiedPreferences"]')

        # This case should not raise an error.
        response = get(self.client, 'questions.details', args=[q.id])
        eq_(200, response.status_code)
Ejemplo n.º 3
0
    def test_empty_troubleshooting_info(self):
        """Test a troubleshooting value that is valid JSON, but junk.
        This should trigger the parser to return None, which should not
        cause a 500.
        """
        q = QuestionFactory()
        q.add_metadata(troubleshooting='{"foo": "bar"}')

        # This case should not raise an error.
        response = get(self.client, "questions.details", args=[q.id])
        eq_(200, response.status_code)
Ejemplo n.º 4
0
    def test_empty_troubleshooting_info(self):
        """Test a troubleshooting value that is valid JSON, but junk.
        This should trigger the parser to return None, which should not
        cause a 500.
        """
        q = QuestionFactory()
        q.add_metadata(troubleshooting='{"foo": "bar"}')

        # This case should not raise an error.
        response = get(self.client, 'questions.details', args=[q.id])
        eq_(200, response.status_code)
Ejemplo n.º 5
0
class TestQuestionMetadata(TestCaseBase):
    """Tests handling question metadata"""

    def setUp(self):
        super(TestQuestionMetadata, self).setUp()

        # add a new Question to test with
        self.question = QuestionFactory(title='Test Question', content='Lorem Ipsum Dolor')

    def test_add_metadata(self):
        """Test the saving of metadata."""
        metadata = {'version': u'3.6.3', 'os': u'Windows 7'}
        self.question.add_metadata(**metadata)
        saved = QuestionMetaData.objects.filter(question=self.question)
        eq_(dict((x.name, x.value) for x in saved), metadata)

    def test_metadata_property(self):
        """Test the metadata property on Question model."""
        self.question.add_metadata(crash_id='1234567890')
        eq_('1234567890', self.question.metadata['crash_id'])

    def test_product_property(self):
        """Test question.product property."""
        self.question.add_metadata(product='desktop')
        eq_(config.products['desktop'], self.question.product_config)

    def test_category_property(self):
        """Test question.category property."""
        self.question.add_metadata(product='desktop')
        self.question.add_metadata(category='fix-problems')
        eq_(config.products['desktop']['categories']['fix-problems'],
            self.question.category_config)

    def test_clear_mutable_metadata(self):
        """Make sure it works and clears the internal cache.

        crash_id should get cleared, while product, category, and useragent
        should remain.

        """
        q = self.question
        q.add_metadata(product='desktop', category='fix-problems',
                       useragent='Fyerfocks', crash_id='7')

        q.metadata
        q.clear_mutable_metadata()
        md = q.metadata
        assert 'crash_id' not in md, \
            "clear_mutable_metadata() didn't clear the cached metadata."
        eq_(dict(product='desktop', category='fix-problems',
                 useragent='Fyerfocks'),
            md)

    def test_auto_tagging(self):
        """Make sure tags get applied based on metadata on first save."""
        Tag.objects.create(slug='green', name='green')
        Tag.objects.create(slug='Fix problems', name='fix-problems')
        q = self.question
        q.add_metadata(product='desktop', category='fix-problems',
                       ff_version='3.6.8', os='GREen')
        q.save()
        q.auto_tag()
        tags_eq(q, ['desktop', 'fix-problems', 'Firefox 3.6.8', 'Firefox 3.6',
                    'green'])

    def test_auto_tagging_aurora(self):
        """Make sure versions with prerelease suffix are tagged properly."""
        q = self.question
        q.add_metadata(ff_version='18.0a2')
        q.save()
        q.auto_tag()
        tags_eq(q, ['Firefox 18.0'])

    def test_auto_tagging_restraint(self):
        """Auto-tagging shouldn't tag unknown Firefox versions or OSes."""
        q = self.question
        q.add_metadata(ff_version='allyourbase', os='toaster 1.0')
        q.save()
        q.auto_tag()
        tags_eq(q, [])

    def test_tenths_version(self):
        """Test the filter that turns 1.2.3 into 1.2."""
        eq_(_tenths_version('1.2.3beta3'), '1.2')
        eq_(_tenths_version('1.2rc'), '1.2')
        eq_(_tenths_version('1.w'), '')

    def test_has_beta(self):
        """Test the _has_beta helper."""
        assert _has_beta('5.0', {'5.0b3': '2011-06-01'})
        assert not _has_beta('6.0', {'5.0b3': '2011-06-01'})
        assert not _has_beta('5.5', {'5.0b3': '2011-06-01'})
        assert _has_beta('5.7', {'5.7b1': '2011-06-01'})
        assert _has_beta('11.0', {'11.0b7': '2011-06-01'})
        assert not _has_beta('10.0', {'11.0b7': '2011-06-01'})
Ejemplo n.º 6
0
class TestQuestionMetadata(TestCaseBase):
    """Tests handling question metadata"""

    def setUp(self):
        super(TestQuestionMetadata, self).setUp()

        # add a new Question to test with
        self.question = QuestionFactory(
            title="Test Question", content="Lorem Ipsum Dolor"
        )

    def test_add_metadata(self):
        """Test the saving of metadata."""
        metadata = {'version': '3.6.3', 'os': 'Windows 7'}
        self.question.add_metadata(**metadata)
        saved = QuestionMetaData.objects.filter(question=self.question)
        eq_(dict((x.name, x.value) for x in saved), metadata)

    def test_metadata_property(self):
        """Test the metadata property on Question model."""
        self.question.add_metadata(crash_id="1234567890")
        eq_("1234567890", self.question.metadata["crash_id"])

    def test_product_property(self):
        """Test question.product property."""
        self.question.add_metadata(product="desktop")
        eq_(config.products["desktop"], self.question.product_config)

    def test_category_property(self):
        """Test question.category property."""
        self.question.add_metadata(product="desktop")
        self.question.add_metadata(category="fix-problems")
        eq_(
            config.products["desktop"]["categories"]["fix-problems"],
            self.question.category_config,
        )

    def test_clear_mutable_metadata(self):
        """Make sure it works and clears the internal cache.

        crash_id should get cleared, while product, category, and useragent
        should remain.

        """
        q = self.question
        q.add_metadata(
            product="desktop",
            category="fix-problems",
            useragent="Fyerfocks",
            crash_id="7",
        )

        q.metadata
        q.clear_mutable_metadata()
        md = q.metadata
        assert (
            "crash_id" not in md
        ), "clear_mutable_metadata() didn't clear the cached metadata."
        eq_(dict(product="desktop", category="fix-problems", useragent="Fyerfocks"), md)

    def test_auto_tagging(self):
        """Make sure tags get applied based on metadata on first save."""
        Tag.objects.create(slug="green", name="green")
        Tag.objects.create(slug="Fix problems", name="fix-problems")
        q = self.question
        q.add_metadata(
            product="desktop", category="fix-problems", ff_version="3.6.8", os="GREen"
        )
        q.save()
        q.auto_tag()
        tags_eq(q, ["desktop", "fix-problems", "Firefox 3.6.8", "Firefox 3.6", "green"])

    def test_auto_tagging_aurora(self):
        """Make sure versions with prerelease suffix are tagged properly."""
        q = self.question
        q.add_metadata(ff_version="18.0a2")
        q.save()
        q.auto_tag()
        tags_eq(q, ["Firefox 18.0"])

    def test_auto_tagging_restraint(self):
        """Auto-tagging shouldn't tag unknown Firefox versions or OSes."""
        q = self.question
        q.add_metadata(ff_version="allyourbase", os="toaster 1.0")
        q.save()
        q.auto_tag()
        tags_eq(q, [])

    def test_tenths_version(self):
        """Test the filter that turns 1.2.3 into 1.2."""
        eq_(_tenths_version("1.2.3beta3"), "1.2")
        eq_(_tenths_version("1.2rc"), "1.2")
        eq_(_tenths_version("1.w"), "")

    def test_has_beta(self):
        """Test the _has_beta helper."""
        assert _has_beta("5.0", {"5.0b3": "2011-06-01"})
        assert not _has_beta("6.0", {"5.0b3": "2011-06-01"})
        assert not _has_beta("5.5", {"5.0b3": "2011-06-01"})
        assert _has_beta("5.7", {"5.7b1": "2011-06-01"})
        assert _has_beta("11.0", {"11.0b7": "2011-06-01"})
        assert not _has_beta("10.0", {"11.0b7": "2011-06-01"})
Ejemplo n.º 7
0
class TestQuestionMetadata(TestCaseBase):
    """Tests handling question metadata"""
    def setUp(self):
        super(TestQuestionMetadata, self).setUp()

        # add a new Question to test with
        self.question = QuestionFactory(title='Test Question',
                                        content='Lorem Ipsum Dolor')

    def test_add_metadata(self):
        """Test the saving of metadata."""
        metadata = {'version': u'3.6.3', 'os': u'Windows 7'}
        self.question.add_metadata(**metadata)
        saved = QuestionMetaData.objects.filter(question=self.question)
        eq_(dict((x.name, x.value) for x in saved), metadata)

    def test_metadata_property(self):
        """Test the metadata property on Question model."""
        self.question.add_metadata(crash_id='1234567890')
        eq_('1234567890', self.question.metadata['crash_id'])

    def test_product_property(self):
        """Test question.product property."""
        self.question.add_metadata(product='desktop')
        eq_(config.products['desktop'], self.question.product_config)

    def test_category_property(self):
        """Test question.category property."""
        self.question.add_metadata(product='desktop')
        self.question.add_metadata(category='fix-problems')
        eq_(config.products['desktop']['categories']['fix-problems'],
            self.question.category_config)

    def test_clear_mutable_metadata(self):
        """Make sure it works and clears the internal cache.

        crash_id should get cleared, while product, category, and useragent
        should remain.

        """
        q = self.question
        q.add_metadata(product='desktop',
                       category='fix-problems',
                       useragent='Fyerfocks',
                       crash_id='7')

        q.metadata
        q.clear_mutable_metadata()
        md = q.metadata
        assert 'crash_id' not in md, \
            "clear_mutable_metadata() didn't clear the cached metadata."
        eq_(
            dict(product='desktop',
                 category='fix-problems',
                 useragent='Fyerfocks'), md)

    def test_auto_tagging(self):
        """Make sure tags get applied based on metadata on first save."""
        Tag.objects.create(slug='green', name='green')
        Tag.objects.create(slug='Fix problems', name='fix-problems')
        q = self.question
        q.add_metadata(product='desktop',
                       category='fix-problems',
                       ff_version='3.6.8',
                       os='GREen')
        q.save()
        q.auto_tag()
        tags_eq(q, [
            'desktop', 'fix-problems', 'Firefox 3.6.8', 'Firefox 3.6', 'green'
        ])

    def test_auto_tagging_aurora(self):
        """Make sure versions with prerelease suffix are tagged properly."""
        q = self.question
        q.add_metadata(ff_version='18.0a2')
        q.save()
        q.auto_tag()
        tags_eq(q, ['Firefox 18.0'])

    def test_auto_tagging_restraint(self):
        """Auto-tagging shouldn't tag unknown Firefox versions or OSes."""
        q = self.question
        q.add_metadata(ff_version='allyourbase', os='toaster 1.0')
        q.save()
        q.auto_tag()
        tags_eq(q, [])

    def test_tenths_version(self):
        """Test the filter that turns 1.2.3 into 1.2."""
        eq_(_tenths_version('1.2.3beta3'), '1.2')
        eq_(_tenths_version('1.2rc'), '1.2')
        eq_(_tenths_version('1.w'), '')

    def test_has_beta(self):
        """Test the _has_beta helper."""
        assert _has_beta('5.0', {'5.0b3': '2011-06-01'})
        assert not _has_beta('6.0', {'5.0b3': '2011-06-01'})
        assert not _has_beta('5.5', {'5.0b3': '2011-06-01'})
        assert _has_beta('5.7', {'5.7b1': '2011-06-01'})
        assert _has_beta('11.0', {'11.0b7': '2011-06-01'})
        assert not _has_beta('10.0', {'11.0b7': '2011-06-01'})