예제 #1
0
파일: api.py 프로젝트: Puppet-Finland/trac
    def test_train_ham(self):
        req = MockRequest(self.env, path_info='/foo')
        entry = LogEntry(self.env, time.time(), '/foo', 'john', False,
                         '127.0.0.1', '', 'Test', True, -5, [], req)
        entry.insert()
        FilterSystem(self.env).train(req, entry.id, spam=False)

        strategy = DummyStrategy(self.env)
        self.assertEqual(True, strategy.train_called)
        self.assertEqual('john', strategy.author)
        self.assertEqual('Test', strategy.content)
        self.assertEqual(False, strategy.spam)

        log = list(LogEntry.select(self.env))
        self.assertEqual(1, len(log))
        entry = log[0]
        self.assertEqual(False, entry.rejected)
예제 #2
0
    def test_train_ham(self):
        entry = LogEntry(self.env, time.time(), "/foo", "john", False, "127.0.0.1", "", "Test", True, -5, [])
        entry.insert()

        req = Mock(
            environ={"SERVER_NAME": "localhost", "SERVER_PORT": "80", "wsgi.url_scheme": "http"},
            path_info="/foo",
            authname="anonymous",
            remote_addr="127.0.0.1",
        )
        FilterSystem(self.env).train(req, entry.id, spam=False)

        strategy = DummyStrategy(self.env)
        self.assertEqual(True, strategy.train_called)
        self.assertEqual("john", strategy.author)
        self.assertEqual("Test", strategy.content)
        self.assertEqual(False, strategy.spam)

        log = list(LogEntry.select(self.env))
        self.assertEqual(1, len(log))
        entry = log[0]
        self.assertEqual(False, entry.rejected)