Exemplo n.º 1
0
 def all_nodes__stats(self):
     keys = list_set(self.all_nodes)
     result = {}
     all_nodes = self.all_nodes
     for key in keys:
         key_nodes = all_nodes[key]
         result[key] = {'size': len(key_nodes)}
     return result
Exemplo n.º 2
0
 def server_list(self):
     raw_stats = self.stats()
     pxname = list_group_by(raw_stats, '# pxname')
     icap_pool = pxname.get('icap_pool')
     servers = list_index_by(icap_pool, 'svname')
     if servers.get('BACKEND'):
         del servers['BACKEND']  # this row is the totals
     return list_set(servers)
Exemplo n.º 3
0
 def test_info(self):
     pod_info = self.pod.info()
     del pod_info['id']
     del pod_info['start_time']
     assert list_set(pod_info) == [
         'image', 'ip', 'name', 'namespace', 'phase'
     ]
     assert pod_info['name'] == self.pod_name
Exemplo n.º 4
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['id', 'init', 'type']
     self.id = js_ast.get('id')
     self.init = js_ast.get('init')
     self.id_node = None
     self.init_node = None
     self.name = None
     self.value = None
Exemplo n.º 5
0
    def test_dom(self):
        dom = self.py_query_dom.dom()
        assert list_set(dom)          == ['attributes', 'children', 'tag', 'text']
        assert dom['tag']             == 'html'
        assert len(dom['attributes']) == 1
        assert len(dom['children'  ]) == 2
        assert len(dom['text'      ]) == 1540

        children = dom['children']
        child_element = children[0]

        assert list_set(children) == [0,1]
        assert list_set(child_element) == ['attributes', 'children', 'tag', 'text']
        assert child_element['tag'] == 'head'
        assert len(child_element['attributes']) == 0
        assert len(child_element['children'  ]) == 6
        assert len(child_element['text'      ]) == 187

        assert child_element.get('children')[0].get('attributes') == {'charset': 'UTF-8'}
Exemplo n.º 6
0
 def test_queue_info(self):
     result = self.sqs.queue_info(queue_url=self.queue_url)
     assert list_set(result) == [
         'ApproximateNumberOfMessages',
         'ApproximateNumberOfMessagesDelayed',
         'ApproximateNumberOfMessagesNotVisible', 'CreatedTimestamp',
         'DelaySeconds', 'LastModifiedTimestamp', 'MaximumMessageSize',
         'MessageRetentionPeriod', 'Policy', 'QueueArn', 'QueueName',
         'QueueUrl', 'ReceiveMessageWaitTimeSeconds', 'VisibilityTimeout'
     ]
Exemplo n.º 7
0
 def indexed_by_attribute(self, attribute_name, return_unique_list=False):
     result = {}
     items = self.items()
     for item in items:
         attribute_value = item.attribute(attribute_name)
         if attribute_value:
             result[attribute_value] = item
     if return_unique_list:
         return list_set(result)
     return result
Exemplo n.º 8
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == [
         'computed', 'key', 'kind', 'method', 'shorthand', 'type', 'value'
     ]
     self.computed = js_ast.get('computed')
     self.key = js_ast.get('key')
     self.kind = js_ast.get('kind')
     self.method = js_ast.get('method')
     self.shorthand = js_ast.get('shorthand')
     self.value = js_ast.get('value')
Exemplo n.º 9
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == [
         'block', 'finalizer', 'guardedHandlers', 'handler', 'handlers',
         'type'
     ]
     self.block = js_ast.get('block')
     self.finalizer = js_ast.get('finalizer')
     self.guardedHandlers = js_ast.get('guardedHandlers')
     self.handler = js_ast.get('handler')
     self.handlers = js_ast.get('handlers')
Exemplo n.º 10
0
 def test_get_values(self):
     values = self.config.values()
     assert self.config.values().get(
         'root_folder') == self.config.root_folder
     assert list_set(values) == [
         'elastic_host', 'elastic_port', 'elastic_schema', 'endpoints',
         'hd1_location', 'hd2_data_location', 'hd2_location',
         'hd2_processed_location', 'hd2_status_location', 'hd3_location',
         'kibana_host', 'kibana_port', 'request_timeout', 'root_folder',
         'thread_count'
     ]
    def test_user_privs(self):
        user_name = 'AlekhAnejaUpwork'
        access_key_id = 'AKIA3NUU5XSYZRQYXMP2'
        iam_user = IAM(user_name=user_name)

        assert iam_user.user_exists()
        assert list_set(iam_user.user_access_keys(index_by='AccessKeyId')) == [
            access_key_id
        ]

        pprint(iam_user.user_polices())
Exemplo n.º 12
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == [
         'body', 'defaults', 'expression', 'generator', 'id', 'params',
         'type'
     ]
     self.body = js_ast.get('body')
     self.defaults = js_ast.get('defaults')
     self.expression = js_ast.get('expression')
     self.generator = js_ast.get('generator')
     self.id = js_ast.get('id')
     self.params = js_ast.get('params')
 def test_create_info_exists_delete(self):
     result = self.index_pattern.create()
     #pprint(result)
     assert result.get('attributes').get('title') == self.pattern_name
     assert self.index_pattern.exists() is True
     assert list_set(self.index_pattern.info()) == [
         'fields', 'id', 'namespaces', 'references', 'score', 'title',
         'type', 'updated_at'
     ]
     assert Index_Pattern(kibana=self.kibana,
                          pattern_name=random_text()).info() == {}
     assert self.index_pattern.delete() is True
    def test_critical_debug_error_info_warning(self):
        message = random_text()
        self.logging.critical(message)
        self.logging.debug(message)
        self.logging.error(message)
        self.logging.info(message)
        self.logging.warning(message)
        messages = self.elastic.search_using_lucene(message, index_by='level')

        assert list_set(messages) == [
            'CRITICAL', 'DEBUG', 'ERROR', 'INFO', 'WARNING'
        ]
        assert messages['ERROR'].get('message') == message
Exemplo n.º 15
0
 def namespace_metrics(self,
                       namespace,
                       metric_name=None,
                       dimensions=None,
                       recently_active='PT3H'):
     result = self.metric_list(namespace=namespace,
                               metric_name=metric_name,
                               dimensions=dimensions,
                               recently_active=recently_active)
     namespace_data = result.get(namespace, {})
     metrics = {}
     for metric_name, metric_data in namespace_data.items():
         metrics[metric_name] = list_set(metric_data)
     return metrics
Exemplo n.º 16
0
    def test_pods(self):
        result = self.kubectl.pods()
        item = result.get('items').pop()
        spec = item.get('spec')
        status = item.get('status')
        kind = item.get('kind')
        metadata = item.get('metadata')
        container = spec.get('containers').pop()

        assert list_set(result) == ['apiVersion', 'items', 'kind', 'metadata']
        assert list_set(item) == [
            'apiVersion', 'kind', 'metadata', 'spec', 'status'
        ]
        assert list_set(spec) == [
            'containers', 'dnsPolicy', 'enableServiceLinks', 'hostname',
            'nodeName', 'priority', 'restartPolicy', 'schedulerName',
            'securityContext', 'serviceAccount', 'serviceAccountName',
            'subdomain', 'terminationGracePeriodSeconds', 'tolerations',
            'volumes'
        ]
        assert list_set(status) == [
            'conditions', 'containerStatuses', 'hostIP', 'phase', 'podIP',
            'podIPs', 'qosClass', 'startTime'
        ]
        assert list_set(metadata) == [
            'annotations', 'creationTimestamp', 'generateName', 'labels',
            'managedFields', 'name', 'namespace', 'ownerReferences',
            'resourceVersion', 'selfLink', 'uid'
        ]
        assert list_set(container) == [
            'args', 'command', 'env', 'image', 'imagePullPolicy', 'name',
            'ports', 'resources', 'terminationMessagePath',
            'terminationMessagePolicy', 'volumeMounts'
        ]
        assert kind == 'Pod'

        pod_namespace = metadata.get('namespace')
        pod_name = metadata.get('name')
        container_name = container.get('name')

        exec_command = "uname"
        result_exec = self.kubectl.pod_exec(pod_namespace, pod_name,
                                            container_name, exec_command)
        result_logs = self.kubectl.pod_logs(pod_namespace, pod_name,
                                            container_name)

        assert len(result_logs) > 0
        assert result_exec == 'Linux\n'
Exemplo n.º 17
0
    def test__enter__exit__(self):
        headless = True
        with Temp_Browser(headless=headless) as browser:
            browser.open('https://www.google.com')
            assert browser.api_browser.sync__url() == 'https://www.google.com/'

            raw_html = browser.html()
            py_query = browser.py_query()
            assert "<title>Google</title>" in raw_html
            assert py_query.query('title').text() == 'Google'
            assert py_query.query('form').attributes() == {
                'action': '/search',
                'method': 'GET',
                'role': 'search'
            }
            scripts_urls = list_set(
                py_query.query('script').indexed_by_attribute('src'))
            first_script = scripts_urls[0]
            js_parser = js_parser_from_url(first_script)

            assert len(js_parser.var_names()) > 300
            assert len(js_parser.function_names()) > 10
            assert len(js_parser.identifier_names()) > 1000
            literals_with_https = js_parser.literal_names(
                min_name_size=5, starts_with='"https://')
            assert literals_with_https == [
                '"https://accounts.google.com/o/oauth2/auth"',
                '"https://accounts.google.com/o/oauth2/postmessageRelay"',
                '"https://apis.google.com"', '"https://clients6.google.com"',
                '"https://content.googleapis.com"',
                '"https://domains.google.com/suggest/flow"',
                '"https://plus.google.com"', '"https://plus.googleapis.com"',
                '"https://workspace.google.com/:session_prefix:marketplace/appfinder?usegapi=1"',
                '"https://www.googleapis.com/auth/plus.me"',
                '"https://www.googleapis.com/auth/plus.people.recommended"'
            ]
Exemplo n.º 18
0
 def test_hd2_metadatas(self):
     self.add_test_files(count=10, text_size=1000, execute_stage_1=True)
     metadatas = self.storage.hd2_metadatas()
     assert list_set(metadatas[0]) == [ 'error', 'f2f_plugin_git_commit', 'f2f_plugin_version', 'file_name', 'hd1_to_hd2_copy_time', 'hd2_to_hd3_copy_time', 'last_update_time', 'original_file_extension', 'original_file_paths', 'original_file_size', 'original_hash', 'original_hash_calculation_time', 'rebuild_file_duration', 'rebuild_file_extension', 'rebuild_file_path', 'rebuild_file_size', 'rebuild_hash', 'rebuild_server', 'rebuild_status', 'server_version', 'xml_report_status']
Exemplo n.º 19
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['expression', 'type']
     self.expression = js_ast.get('expression')
 def test_now(self):
     result = self.status.now()
     assert list_set(result) == ['check_logging', 'config', 'date']
     assert result.get('config') == Config().values()
Exemplo n.º 21
0
 def test_list_set(self):
     test_set = {3, 2, 1}
     sorted_list = list_set(test_set)
     assert sorted_list == sorted(list(test_set))
Exemplo n.º 22
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['computed', 'object', 'property', 'type']
     self.computed = js_ast.get('computed')
     self.object = js_ast.get('object')
     self.property = js_ast.get('property')
Exemplo n.º 23
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['body', 'param', 'type']
     self.body = js_ast.get('body')
     self.param = js_ast.get('param')
Exemplo n.º 24
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['argument', 'operator', 'prefix', 'type']
     self.argument = js_ast.get('argument')
     self.operator = js_ast.get('operator')
     self.prefix = js_ast.get('prefix')
Exemplo n.º 25
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['name', 'type']
     self.name = js_ast.get('name')
Exemplo n.º 26
0
 def test_alarms(self):
     result = self.cloud_watch.alarms()
     assert list_set(result) == ['composite_alarms', 'metric_alarms']
Exemplo n.º 27
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['type']
Exemplo n.º 28
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['elements', 'type']
     self.elements = js_ast.get('elements')
Exemplo n.º 29
0
 def __init__(self, js_ast, all_nodes):
     super().__init__(js_ast, all_nodes)
     assert list_set(js_ast) == ['properties', 'type']
     self.properties = js_ast.get('properties')
Exemplo n.º 30
0
 def groups_names(self):
     return list_set(self.groups(index_by='logGroupName'))