예제 #1
0
    def test_display_name_not_exists(self):
        target = Target()
        target.add_hearts = Mock()
        target.get_from_database = Mock()
        target.get_from_database.return_value = [{
            "_id": {
                "type": "brand",
                "key": "ash"
            },
            "aliases": [{
                "value": "ash",
                "language": "en"
            }]
        }]

        actual = target.load(["en"])

        self.assertDictEqual(
            actual, {
                'en': {
                    'ash': [{
                        'type': 'brand',
                        'key': 'ash',
                        'source': 'content',
                        'display_name': 'ash',
                        'match_type': 'alias'
                    }]
                }
            })
        self.assertEqual(target.add_hearts.call_count, 1)
예제 #2
0
    def test_display_name_not_exists(self):
        target = Target()
        target.add_hearts = Mock()
        target.get_from_database = Mock()
        target.get_from_database.return_value = [
            {
                "_id": {
                    "type": "brand",
                    "key": "ash"
                },
                "aliases": [
                    {
                        "value": "ash",
                        "language": "en"
                    }
                ]
            }
        ]

        actual = target.load(["en"])

        self.assertDictEqual(
            actual,
            {
                'en': {
                    'ash': [{'type': 'brand', 'key': 'ash', 'source': 'content', 'display_name': 'ash',
                             'match_type': 'alias'}]
                }
            }
        )
        self.assertEqual(
            target.add_hearts.call_count,
            1
        )
예제 #3
0
    def test_spelling_mistakes(self):
        target = Target()
        target.add_hearts = Mock()
        target.get_from_database = Mock()
        target.get_from_database.return_value = [
            {
                "_id": {
                    "type": "color",
                    "key": "citrus"
                },
                "aliases": [
                    {
                        "value": "citrus",
                        "language": "en"
                    },
                    {
                        "value": "agrume",
                        "language": "it"
                    },
                    {
                        "value": "citrin",
                        "language": "fr"
                    },
                    {
                        "value": "citru",
                        "language": "en",
                        "type": "spelling"
                    }
                ]
            }
        ]

        actual = target.load(["en"])

        self.assertDictEqual(
            actual,
            {
                'en': {
                    'citru': [{'type': 'color', 'key': 'citrus', 'source': 'content', 'display_name': 'citrus',
                               'match_type': 'spelling'}],
                    'citrus': [{'type': 'color', 'key': 'citrus', 'source': 'content', 'display_name': 'citrus',
                                'match_type': 'alias'}],
                }
            }
        )

        self.assertEqual(
            target.add_hearts.call_count,
            1
        )
예제 #4
0
    def test_spelling_mistakes(self):
        target = Target()
        target.add_hearts = Mock()
        target.get_from_database = Mock()
        target.get_from_database.return_value = [{
            "_id": {
                "type": "color",
                "key": "citrus"
            },
            "aliases": [{
                "value": "citrus",
                "language": "en"
            }, {
                "value": "agrume",
                "language": "it"
            }, {
                "value": "citrin",
                "language": "fr"
            }, {
                "value": "citru",
                "language": "en",
                "type": "spelling"
            }]
        }]

        actual = target.load(["en"])

        self.assertDictEqual(
            actual, {
                'en': {
                    'citru': [{
                        'type': 'color',
                        'key': 'citrus',
                        'source': 'content',
                        'display_name': 'citrus',
                        'match_type': 'spelling'
                    }],
                    'citrus': [{
                        'type': 'color',
                        'key': 'citrus',
                        'source': 'content',
                        'display_name': 'citrus',
                        'match_type': 'alias'
                    }],
                }
            })

        self.assertEqual(target.add_hearts.call_count, 1)