Esempio n. 1
0
def cache(repo):
    """Cache the given repository to reuse later

    Args:
        repo: A repository instance
    """
    repositories = get_repo_collection()
    repo.update_last_latest_hash()
    repositories.replace_one({'url': repo.url},
                             repo.to_document(),
                             upsert=True)
Esempio n. 2
0
def is_cached(repo):
    """Check if the repository was cached

    Args:
        repo: A repository instance

    Returns:
        Whether if there is cached one or not
    """
    repositories = get_repo_collection()
    repo_doc = repositories.find_one({'url': repo.url})

    if not repo_doc:
        return False
    if repo_doc['last_latest_hash'] != repo.latest_hash:
        return False
    return True
Esempio n. 3
0
 def setUp(self):
     self.repositories = get_repo_collection()
     self.repo = create_repository('github.com/mingrammer/awesome-finder')