Exemplo n.º 1
0
    def test_create_from_dict(self):
        """Test create_from_dict method."""
        data = {
            'username': '******',
            'name': 'napp',
            'version': '1.0',
            'repository': 'any'
        }
        napp = NApp.create_from_dict(data)

        self.assertEqual(napp.username, 'kytos')
        self.assertEqual(napp.name, 'napp')
        self.assertEqual(napp.version, '1.0')
        self.assertEqual(napp.repository, 'any')
Exemplo n.º 2
0
    def search(self, pattern, use_cache=False):
        """Search for NApps in NApp repositories matching a pattern."""
        # ISSUE #347, we need to loop here over all repositories
        repo = eval(self._config.napps_repositories)[0]  # noqa

        if use_cache:
            # ISSUE #346, we should use cache here
            pass

        result = urllib.request.urlretrieve("{}/.database".format(repo))[0]
        with open(result, 'r') as fp:
            napps_json = json.load(fp)

        napps = [NApp.create_from_dict(napp_json) for napp_json in napps_json]
        return [napp for napp in napps if napp.match(pattern)]