From 2d7b4dd1bf29ee54008ea01287b148b9e472a13e Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 18 Jul 2018 17:22:05 -0400 Subject: [PATCH] Move public repo test to pytest --- data/model/test/test_repository.py | 8 ++++++++ test/test_repomodel.py | 32 ------------------------------ 2 files changed, 8 insertions(+), 32 deletions(-) delete mode 100644 test/test_repomodel.py diff --git a/data/model/test/test_repository.py b/data/model/test/test_repository.py index c55d084c1..519794952 100644 --- a/data/model/test/test_repository.py +++ b/data/model/test/test_repository.py @@ -1,3 +1,5 @@ +from datetime import timedelta + import pytest from peewee import IntegrityError @@ -43,3 +45,9 @@ def test_search_pagination(query, authed_username, initialized_db): next_repos = get_filtered_matching_repositories(query, filter_username=authed_username, offset=1) assert repositories[0].id != next_repos[0].id assert repositories[1].id == next_repos[0].id + + +def test_popular_repo_list(initialized_db): + onlypublic = model.repository.list_popular_public_repos(0, timedelta(weeks=1)) + assert len(onlypublic) == 1 + assert onlypublic[0] == ('public', 'publicrepo') diff --git a/test/test_repomodel.py b/test/test_repomodel.py deleted file mode 100644 index fa5f01fc8..000000000 --- a/test/test_repomodel.py +++ /dev/null @@ -1,32 +0,0 @@ -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): - onlypublic = model.repository.list_popular_public_repos(0, timedelta(weeks=1)) - self.assertEquals(len(onlypublic), 1) - self.assertEquals(onlypublic[0], (PUBLIC_USERNAME, PUBLIC_REPONAME)) - - -if __name__ == '__main__': - unittest.main()