How to use _sort method in assertpy

Best Python code snippet using assertpy_python

ast.py

Source:ast.py Github

copy

Full Screen

...140 @classmethod141 def get_signature(cls):142 return cls._signature143 @classmethod144 def get_sort(cls):145 return cls._sort146 @classmethod147 def is_terminal(cls):148 return cls._signature == UNIT_SIGNATURE149 @classmethod150 def accepts(cls, sort):151 if cls._signature == UNCHECKED_SIGNATURE:152 return False153 return sort in cls._signature154 @classmethod155 def returns(cls, sort):156 return sort == cls._sort157# literals158class LiteralNode(_SortedASTNode):159 _signature = UNIT_SIGNATURE160 def __init__(self, value):161 super().__init__()162 self.value = value163 def __repr__(self):164 return '{}<{}>'.format(self.get_sort(), self.value)165class BoolLitNode(LiteralNode):166 _sort = BOOL_SORT167 def __init__(self, value):168 assert isinstance(value, bool)169 super().__init__(value)170class IntLitNode(LiteralNode):171 _sort = INT_SORT172 def __init__(self, value):173 assert isinstance(value, numbers.Real) and not isinstance(value, bool)174 super().__init__(value)175class StringLitNode(LiteralNode):176 _sort = STRING_SORT177 def __init__(self, value):178 assert isinstance(value, str)...

Full Screen

Full Screen

search_queries.py

Source:search_queries.py Github

copy

Full Screen

1import elasticsearch2from elasticsearch_dsl import Search, Q, A3def GetGeneratorQuery(auditgenerator_type, str_query, case, endpoint_id, start, length, sort, order):4 s = Search()5 s = s[int(start):int(length)+int(start)]6 if auditgenerator_type == "w32registryraw":7 order_dict = {8 "0": "Modified",9 "1": "Path",10 "2": "Type",11 "3": "Text",12 "4": "ReportedLengthInBytes",13 "5": "Hive",14 "6": "Username",15 "7": "JobCreated",16 "8": "ValueName",17 "9": "IsKnownKey",18 "10": "KeyPath",19 "11": "SecurityID",20 "12": "Tag",21 "13": "Comment",22 "14": "nHscore"23 }24 if str_query == "":25 _sort = {26 "Record.{0}".format(order_dict[str(sort)]): {27 "order": order28 }29 }30 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case)31 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)32 else:33 _sort = {34 "Record.{0}".format(order_dict[str(sort)]): {35 "order": order36 }37 }38 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case) & Q('query_string', fields=["Record.Path", "Record.Username", "Record.ValueName", "Record.Text", "Record.Tag", "Record.Comment"], query="{0}".format(str_query))39 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)40 return query41 elif auditgenerator_type == "w32eventlogs":42 order_dict = {43 "0": "GenTime",44 "1": "Source",45 "2": "EID",46 "3": "Index",47 "4": "ExecutionProcessId",48 "5": "ExecutionThreadId",49 "6": "Message",50 "7": "Category",51 "8": "Tag",52 "9": "Comment",53 "10": "nHscore"54 }55 if str_query == "":56 _sort = {57 "Record.{0}".format(order_dict[str(sort)]): {58 "order": order59 }60 }61 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case)62 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)63 else:64 _sort = {65 "Record.{0}".format(order_dict[str(sort)]): {66 "order": order67 }68 }69 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case) & Q('query_string', fields=["Record.Message", "Record.EID", "Record.Source", "Record.Index", "Record.ExecutionProcessId", "Record.ExecutionThreadId"], query="{0}".format(str_query))70 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)71 return query72 elif auditgenerator_type == "w32rawfiles":73 order_dict = {74 "0": "FilenameCreated",75 "1": "FilenameModified",76 "2": "FilenameAccessed",77 "3": "FilenameChanged",78 "4": "Username",79 "5": "Path",80 "6": "FileName",81 "7": "FileExtension",82 "8": "SizeInBytes",83 "9": "Md5sum",84 "10": "IsGoodHash",85 "11": "FileAttributes",86 "12": "PeInfo.Type",87 "13": "Comment",88 "14": "nHscore"89 }90 if str_query == "":91 _sort = {92 "Record.{0}".format(order_dict[str(sort)]): {93 "order": order94 }95 }96 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case)97 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)98 else:99 _sort = {100 "Record.{0}".format(order_dict[str(sort)]): {101 "order": order102 }103 }104 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case) & Q('query_string', fields=["Record.FilenameChanged", "Record.FilenameCreated", "Record.FilenameAccessed", "Record.FilenameModified", "Record.Username", "Record.Path", "Record.FileName", "Record.FileExtension", "Record.SizeInBytes"], query="{0}".format(str_query))105 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)106 return query107 elif auditgenerator_type == "w32apifiles":108 order_dict = {109 "0": "Modified",110 "1": "Accessed",111 "2": "Changed",112 "3": "Username",113 "4": "Path",114 "5": "SizeInBytes",115 "6": "Md5sum",116 "7": "IsGoodHash",117 "8": "FileAttributes",118 "9": "IsGoodHash",119 "10": "FileAttributes",120 "11": "PeInfo.Type",121 "12": "Comment",122 "13": "nHscore"123 }124 if str_query == "":125 _sort = {126 "Record.{0}".format(order_dict[str(sort)]): {127 "order": order128 }129 }130 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case)131 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)132 else:133 _sort = {134 "Record.{0}".format(order_dict[str(sort)]): {135 "order": order136 }137 }138 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', default_field="CaseInfo.case_name", query=case) & Q('query_string', fields=["Record.Changed", "Record.Created", "Record.Accessed", "Record.Modified", "Record.Username", "Record.Path", "Record.FileName", "Record.FileExtension", "Record.SizeInBytes"], query="{0}".format(str_query))139 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)140 return query141 elif auditgenerator_type == "filedownloadhistory":142 order_dict = {143 "0": "LastModifiedDate",144 "1": "SourceUrl",145 "2": "Filename",146 "3": "Username",147 "4": "DownloadType",148 "5": "Profile",149 "6": "BrowserName",150 "7": "BrowserVersion",151 "8": "TargetDirectory",152 "9": "FullHttpHeader",153 "10": "LastCheckedDate",154 "11": "BytesDownloaded",155 "12": "CacheFlags",156 "13": "IsGoodFile",157 "14": "Tag",158 "15": "Comment",159 "16": "nHscore"160 }161 if str_query == "":162 _sort = {163 "Record.{0}".format(order_dict[str(sort)]): {164 "order": order165 }166 }167 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id)168 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)169 else:170 _sort = {171 "Record.{0}".format(order_dict[str(sort)]): {172 "order": order173 }174 }175 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', fields=["Record.SourceUrl", "Record.Username", "Record.TargetDirectory", "Record.FullHttpHeader", "Record.Filename", "Record.BrowserName", "Record.Profile", "Record.Tag", "Record.Comment"], query="{0}".format(str_query))176 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)177 return query178 elif auditgenerator_type == "urlhistory":179 order_dict = {180 "0": "LastVisitDate",181 "1": "Hidden",182 "2": "Username",183 "3": "Url",184 "4": "BrowserName",185 "5": "BrowserVersion",186 "6": "PageTitle",187 "7": "VisitFrom",188 "8": "VisitType",189 "9": "IsGoodDomain",190 "10": "IsNewDomain",191 "11": "nHscore",192 "12": "Tag",193 "13": "Comment"194 }195 if str_query == "":196 _sort = {197 "Record.{0}".format(order_dict[str(sort)]): {198 "order": order199 }200 }201 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id)202 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)203 else:204 _sort = {205 "Record.{0}".format(order_dict[str(sort)]): {206 "order": order207 }208 }209 210 t = Q('query_string', default_field="ComputerName.raw", query=endpoint_id) & Q('query_string', fields=["Record.Url", "Record.Username", "Record.Profile"], query="{0}".format(str_query))211 query = s.query(t).filter('term', AuditType__Generator=auditgenerator_type).sort(_sort)...

Full Screen

Full Screen

test_linters.py

Source:test_linters.py Github

copy

Full Screen

...53 Path(f'./{config.PACKAGE_NAME()}').mkdir()54 test_file = Path(f'./{config.PACKAGE_NAME()}/test.py')55 test_file.touch()56 when(_sort)._sort_file(test_file.absolute())57 _sort._sort()58 verifyStubbedInvocationsAreUsed()59def test_isort_test_dir():60 Path('./test').mkdir()61 test_file = Path('./test/test.py')62 test_file.touch()63 when(_sort)._sort_file(test_file.absolute())64 _sort._sort()65 verifyStubbedInvocationsAreUsed()66def test_isort_ignore():67 test_file = Path('./test.py')68 test_file.touch()69 when(_sort.isort).SortImports(70 file_path=test_file.absolute(),71 known_first_party=config.PACKAGE_NAME(),72 **_sort.SETTINGS73 )74 # when(elib_run).run(contains('setup.py isort'))75 _sort._sort()76 verify(_sort.isort, times=0).SortImports(...)77def test_isort_amend():78 # when(elib_run).run(contains('setup.py isort'))79 when(CTX.repo).amend_commit(append_to_msg='sorting imports [auto]')80 _sort._sort(amend=True)81 verifyStubbedInvocationsAreUsed()82def test_isort_stage():83 when(CTX.repo).stage_all()84 _sort._sort(stage=True)85 verifyStubbedInvocationsAreUsed()86# def test_flake8():87# base_cmd = ' '.join((_flake8.IGNORE, _flake8.MAX_LINE_LENGTH, _flake8.EXCLUDE, _flake8.MAX_COMPLEXITY))88# when(elib_run).run(f'flake8 {base_cmd}', mute=True)89# _flake8._flake8()90# verifyStubbedInvocationsAreUsed()91def test_safety():92 when(elib_run).run('safety check --bare', mute=True)93 _safety._safety()94 verifyStubbedInvocationsAreUsed()95@pytest.mark.parametrize(96 'params,cmd',97 [98 ((None, True), 'pylint ./test --reports=y'),...

Full Screen

Full Screen

155_min_stack.py

Source:155_min_stack.py Github

copy

Full Screen

1#!/usr/bin/env python32# -*- coding: utf-8 -*-3"""4Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.5 push(x) -- Push element x onto stack.6 pop() -- Removes the element on top of the stack.7 top() -- Get the top element.8 getMin() -- Retrieve the minimum element in the stack.9Example:10MinStack minStack = new MinStack();11minStack.push(-2);12minStack.push(0);13minStack.push(-3);14minStack.getMin(); --> Returns -3.15minStack.pop();16minStack.top(); --> Returns 0.17minStack.getMin(); --> Returns -2.18"""19class MinStack(object):20 def __init__(self):21 """22 initialize your data structure here.23 """24 self._stack = []25 self._sort = []26 def _add(self, x):27 if not self._sort:28 self._sort.append(x)29 else:30 s, e = 0, len(self._sort) - 131 while s <= e:32 if s == e:33 if x > self._sort[s]:34 self._sort.insert(s + 1, x)35 else:36 self._sort.insert(s, x)37 break38 mid = (s + e) // 239 if x > self._sort[mid]:40 s = mid + 141 else:42 e = mid43 def push(self, x):44 """45 :type x: int46 :rtype: void47 """48 self._stack.append(x)49 self._add(x)50 def pop(self):51 """52 :rtype: void53 """54 element = self._stack.pop()55 self._sort.remove(element)56 def top(self):57 """58 :rtype: int59 """60 return self._stack[-1]61 def getMin(self):62 """63 :rtype: int64 """65 return self._sort[0]66if __name__ == '__main__':67 stack = MinStack()68 stack.push(-2)69 stack.push(0)70 stack.push(-3)71 print(stack.getMin())72 stack.pop()73 print(stack.top())...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run assertpy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful