示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#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))
示例#13
0
    def test_get_updated_field(self):
        base_index = BaseIndex()

        self.assertEquals('modified', base_index.get_updated_field())
示例#14
0
    def test_get_updated_field(self):
        base_index = BaseIndex()

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