Add a sitemap.txt for popular public repos
and reference it from the robots.txt
This commit is contained in:
parent
c712be05e2
commit
a1cf12e460
11 changed files with 146 additions and 52 deletions
37
test/test_repomodel.py
Normal file
37
test/test_repomodel.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import unittest
|
||||
from datetime import timedelta
|
||||
|
||||
from app import app
|
||||
from initdb import setup_database_for_testing, finished_database_for_testing
|
||||
from data import model
|
||||
|
||||
|
||||
PUBLIC_USERNAME = 'public'
|
||||
PUBLIC_REPONAME = 'publicrepo'
|
||||
|
||||
|
||||
class TestRepoModel(unittest.TestCase):
|
||||
def setUp(self):
|
||||
setup_database_for_testing(self)
|
||||
|
||||
self.app = app.test_client()
|
||||
self.ctx = app.test_request_context()
|
||||
self.ctx.__enter__()
|
||||
|
||||
def tearDown(self):
|
||||
finished_database_for_testing(self)
|
||||
self.ctx.__exit__(True, None, None)
|
||||
|
||||
def test_popular_repo_list(self):
|
||||
# Our repository action count table should have 1 event for the only public
|
||||
# repo.
|
||||
onlypublic = model.repository.list_popular_public_repos(0, timedelta(weeks=1))
|
||||
self.assertEquals(len(onlypublic), 1)
|
||||
self.assertEquals(onlypublic[0], (PUBLIC_USERNAME, PUBLIC_REPONAME))
|
||||
|
||||
self.assertEquals(len(model.repository.list_popular_public_repos(1, timedelta(weeks=1))), 1)
|
||||
self.assertEquals(len(model.repository.list_popular_public_repos(50, timedelta(weeks=1))), 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in a new issue