def test_call_without_any_cache(self, get_repositories):
        """Calling the function without disk or in-memory cache."""
        self.assertEquals(
            repositories.query_repositories(), json.loads(REPOSITORIES))

        self.assertEquals(
            repositories.REPOSITORIES, json.loads(REPOSITORIES))
示例#2
0
    def test_call_without_any_cache(self, get_credentials, get):
        """Calling the function without disk or in-memory cache."""
        self.assertEquals(
            repositories.query_repositories(), json.loads(REPOSITORIES))

        self.assertEquals(
            repositories.REPOSITORIES, json.loads(REPOSITORIES))
    def test_call_without_any_cache(self, client):
        """Calling the function without disk or in-memory cache."""
        client.return_value = self.client

        self.assertEquals(repositories.query_repositories(),
                          json.loads(REPOSITORIES))

        self.assertEquals(repositories.REPOSITORIES, json.loads(REPOSITORIES))
示例#4
0
    def test_call_without_any_cache(self, client):
        """Calling the function without disk or in-memory cache."""
        client.return_value = self.client

        self.assertEquals(
            repositories.query_repositories(), json.loads(REPOSITORIES))

        self.assertEquals(
            repositories.REPOSITORIES, json.loads(REPOSITORIES))
示例#5
0
    def test_with_cache_cleared(self, get_repositories):
        """When clear_cache is True query_repositories should ignore both caches."""
        # Using a different 'repositories' mock to make sure
        # query_repositories is using the right one.
        different_repositories = {"real-repo": "repo"}
        repositories.REPOSITORIES = different_repositories
        with open('tmp_repositories.txt', 'w') as f:
            json.dump(different_repositories, f)

        self.assertEquals(
            repositories.query_repositories(clear_cache=True), json.loads(REPOSITORIES))
    def test_with_cache_cleared(self, get_repositories):
        """When clear_cache is True query_repositories should ignore both caches."""
        # Using a different 'repositories' mock to make sure
        # query_repositories is using the right one.
        different_repositories = {"real-repo": "repo"}
        repositories.REPOSITORIES = different_repositories
        with open('tmp_repositories.txt', 'w') as f:
            json.dump(different_repositories, f)

        self.assertEquals(repositories.query_repositories(clear_cache=True),
                          json.loads(REPOSITORIES))
    def test_file_cache(self):
        """Calling the function without in-memory caching but with file cache."""
        repositories.REPOSITORIES = {}

        # Using a different 'repositories' mock to make sure
        # query_repositories is using the right one.
        different_repositories = {"real-repo": "repo"}
        with open('tmp_repositories.txt', 'w') as f:
            json.dump(different_repositories, f)

        self.assertEquals(
            repositories.query_repositories(), different_repositories)
示例#8
0
    def test_file_cache(self):
        """Calling the function without in-memory caching but with file cache."""
        repositories.REPOSITORIES = {}

        # Using a different 'repositories' mock to make sure
        # query_repositories is using the right one.
        different_repositories = {"real-repo": "repo"}
        with open('tmp_repositories.txt', 'w') as f:
            json.dump(different_repositories, f)

        self.assertEquals(
            repositories.query_repositories(), different_repositories)
示例#9
0
def query_repo_name_from_buildername(buildername, clobber=False):
    """
    Return the repository name from a given buildername.

    Raises MozciError if there is no repository name in buildername.
    """
    repositories_list = repositories.query_repositories(clobber)
    ret_val = None
    for repo_name in repositories_list:
        if any(True for iterable in [" %s ", "_%s_", "-%s-"] if iterable % repo_name in buildername):
            ret_val = repo_name
            break

    if ret_val is None and not clobber:
        # Since repositories file is cached, it can be that something has changed.
        # Adding clobber=True will make it overwrite the cached version with latest one.
        query_repo_name_from_buildername(buildername, clobber=True)

    if ret_val is None:
        raise MozciError("Repository name not found in buildername. " "Please provide a correct buildername.")

    return ret_val
示例#10
0
def query_repo_name_from_buildername(buildername, clobber=False):
    """
    Return the repository name from a given buildername.

    Raises MozciError if there is no repository name in buildername.
    """
    repositories_list = repositories.query_repositories(clobber)
    ret_val = None
    for repo_name in repositories_list:
        if any(True for iterable in [' %s ', '_%s_', '-%s-']
               if iterable % repo_name in buildername):
            ret_val = repo_name
            break

    if ret_val is None and not clobber:
        # Since repositories file is cached, it can be that something has changed.
        # Adding clobber=True will make it overwrite the cached version with latest one.
        query_repo_name_from_buildername(buildername, clobber=True)

    if ret_val is None:
        raise MozciError("Repository name not found in buildername. "
                         "Please provide a correct buildername.")

    return ret_val
示例#11
0
 def test_in_memory_cache(self):
     """Calling the function without disk cache but with in-memory cache."""
     repositories.REPOSITORIES = json.loads(REPOSITORIES)
     self.assertEquals(
         repositories.query_repositories(), json.loads(REPOSITORIES))
示例#12
0
 def test_in_memory_cache(self):
     """Calling the function without disk cache but with in-memory cache."""
     repositories.REPOSITORIES = json.loads(REPOSITORIES)
     self.assertEquals(repositories.query_repositories(),
                       json.loads(REPOSITORIES))