Esempio n. 1
0
    def test_prepare_author_url(self):
        base_index = BaseIndex()
        setattr(base_index, "author_obj", None)

        self.assertEquals(None, base_index.prepare_author_url(None))

        base_index.author_obj = Mock(get_absolute_url=lambda: "url_test")
        self.assertEquals("url_test", base_index.prepare_author_url(None))
Esempio n. 2
0
    def test_prepare_author_url(self):
        base_index = BaseIndex()
        setattr(base_index, 'author_obj', None)

        self.assertEquals(None, base_index.prepare_author_url(None))

        base_index.author_obj = Mock(get_absolute_url=lambda: "url_test")
        self.assertEquals("url_test", base_index.prepare_author_url(None))
Esempio n. 3
0
    def test_get_boost(self):
        obj = Mock(hits=10)
        base_index = BaseIndex()

        self.assertEquals(1, base_index.get_boost(obj))

        obj = Mock(hits=11)
        self.assertEquals(math.log(11), base_index.get_boost(obj))
Esempio n. 4
0
    def test_get_boost(self):
        obj = Mock(hits=10)
        base_index = BaseIndex()

        self.assertEquals(1, base_index.get_boost(obj))

        obj = Mock(hits=11)
        self.assertEquals(math.log(11), base_index.get_boost(obj))
Esempio n. 5
0
    def test_prepare_author(self):
        obj = Mock(author="author")
        base_index = BaseIndex()
        setattr(base_index, 'author_obj', None)

        self.assertEquals("author", base_index.prepare_author(obj))

        base_index.author_obj = Mock(username="******")
        self.assertEquals("carlin", base_index.prepare_author(obj))
Esempio n. 6
0
    def test_prepare_author(self):
        obj = Mock(author="author")
        base_index = BaseIndex()
        setattr(base_index, "author_obj", None)

        self.assertEquals("author", base_index.prepare_author(obj))

        base_index.author_obj = Mock(username="******")
        self.assertEquals("carlin", base_index.prepare_author(obj))
Esempio n. 7
0
    def test_prepare_modified_by_url(self):
        base_index = BaseIndex()
        setattr(base_index, "author_obj", None)

        self.assertEquals(None, base_index.prepare_modified_by_url(None))

        base_index.author_obj = Mock(get_absolute_url=lambda: "urlurl")
        self.assertEquals("urlurl", base_index.prepare_modified_by_url(None))

        mock_modified_by = Mock(get_absolute_url=lambda: "urlurl")
        obj = Mock(modified_by="somebody", get_modified_by=lambda: mock_modified_by)

        self.assertEquals("urlurl", base_index.prepare_modified_by_url(obj))
Esempio n. 8
0
    def test_prepare_modified_by(self):
        base_index = BaseIndex()
        setattr(base_index, "author_obj", None)
        obj = self.AuthorMockObject()

        self.assertEquals("author", base_index.prepare_modified_by(obj))

        base_index.author_obj = Mock(get_full_name=lambda: "full_name")
        self.assertEquals("full_name", base_index.prepare_modified_by(obj))

        mock_modified_by = Mock(get_full_name=lambda: "full_name")
        obj = Mock(modified_by="somebody", get_modified_by=lambda: mock_modified_by)

        self.assertEquals("full_name", base_index.prepare_modified_by(obj))
Esempio n. 9
0
    def test_prepare_fullname_and_username(self):
        base_index = BaseIndex()
        setattr(base_index, "author_obj", Mock(username="******", get_full_name=lambda: "name"))

        expected = "{}\n{}".format("name", "user")
        self.assertEquals(expected, base_index.prepare_fullname_and_username(None))

        base_index.author_obj = None
        obj = self.AuthorMockObject()
        self.assertEquals("author", base_index.prepare_fullname_and_username(obj))

        mock_modified_by = Mock(get_full_name=lambda: "full_name", username="******")
        obj = Mock(modified_by="somebody", get_modified_by=lambda: mock_modified_by)

        expected = "{}\n{}".format("full_name", "user")
        self.assertEquals(expected, base_index.prepare_fullname_and_username(obj))
Esempio n. 10
0
    def test_prepare_modified_by_url(self):
        base_index = BaseIndex()
        setattr(base_index, 'author_obj', None)

        self.assertEquals(None, base_index.prepare_modified_by_url(None))

        base_index.author_obj = Mock(get_absolute_url=lambda: "urlurl")
        self.assertEquals("urlurl", base_index.prepare_modified_by_url(None))

        mock_modified_by = Mock(get_absolute_url=lambda: "urlurl")
        obj = Mock(modified_by="somebody",
                   get_modified_by=lambda: mock_modified_by)

        self.assertEquals("urlurl", base_index.prepare_modified_by_url(obj))
Esempio n. 11
0
    def test_prepare_modified_by(self):
        base_index = BaseIndex()
        setattr(base_index, 'author_obj', None)
        obj = self.AuthorMockObject()

        self.assertEquals("author", base_index.prepare_modified_by(obj))

        base_index.author_obj = Mock(get_full_name=lambda: "full_name")
        self.assertEquals("full_name", base_index.prepare_modified_by(obj))

        mock_modified_by = Mock(get_full_name=lambda: "full_name")
        obj = Mock(modified_by="somebody",
                   get_modified_by=lambda: mock_modified_by)

        self.assertEquals("full_name", base_index.prepare_modified_by(obj))
Esempio n. 12
0
    def test_prepare_fullname_and_username(self):
        base_index = BaseIndex()
        setattr(base_index, 'author_obj', Mock(username="******",
                                               get_full_name=lambda: "name"))

        expected = "{}\n{}".format("name", "user")
        self.assertEquals(expected,
                          base_index.prepare_fullname_and_username(None))

        base_index.author_obj = None
        obj = self.AuthorMockObject()
        self.assertEquals("author",
                          base_index.prepare_fullname_and_username(obj))

        mock_modified_by = Mock(get_full_name=lambda: "full_name",
                                username="******")
        obj = Mock(modified_by="somebody",
                   get_modified_by=lambda: mock_modified_by)

        expected = "{}\n{}".format("full_name", "user")
        self.assertEquals(expected,
                          base_index.prepare_fullname_and_username(obj))
Esempio n. 13
0
    def test_get_updated_field(self):
        base_index = BaseIndex()

        self.assertEquals('modified', base_index.get_updated_field())
Esempio n. 14
0
    def test_get_updated_field(self):
        base_index = BaseIndex()

        self.assertEquals("modified", base_index.get_updated_field())