def test_class_condition_satisfied_by_instances(self): class A: pass isAnA = Condition(A) anA = A() self.assertTrue(isAnA.matches(anA))
def test_class_condition_not_satisfied_by_instances_of_supertypes(self): class A: pass class B(A): pass isAB = Condition(B) anA = A() self.assertFalse(isAB.matches(A))
def test_class_condition_satisfied_by_instances_of_subtypes(self): class A: pass class B(A): pass isAnA = Condition(A) aB = B() self.assertTrue(isAnA.matches(aB))
def __parse( self ): with open( self.file_name, 'r' ) as result_file: result_reader = csv.DictReader( result_file, delimiter=',') for row in result_reader: topic = Topic.create_or_update( row['topic'] ) user = User.create_or_update( row['userid'] ) condition = Condition.create_or_update( row['condition'] ) autocomplete = row['autocomplete_used'] == 1 query = Query.create_or_update( row['queryid'], topic = topic, user = user, condition = condition, autocomplete = autocomplete, query_text = row['terms'], precision = self.__build_precision_dict( row ) )
def process_submission(self, sms, sub_type, return_submission=False): """Método que realiza o processamento de submissões novas e retorna uma resposta ao usuário""" # Defaults submission_status = Submission.NOT_CONFIRMED if self.requires_confirmation else Submission.CONFIRMED default_answer = self.ans_default or Config.get("ans_confirmed") \ if not self.requires_confirmation else self.ans_waiting_confirmation # Form conditions action, answer, new_value, extra_vars = Condition.process_conditions(self.conditions.all(), sms.text) if new_value: sms.text = new_value if action == Submission.CANCELED and answer: self.save_submission(sms, action) return answer # Fields parsing text_fields = self.split_fields(sms.text) if len(text_fields) != self.fields.count(): submission = self.save_submission(sms, Submission.INVALID, text_fields, raw=True) processed_answer = self.ans_incorrect_num_fields else: instance_fields = self.instatiate_fields(text_fields) # Fields conditions action, answer = self.process_field_conditions(instance_fields) if action: submission_status = action context = self.get_context(instance_fields) if context and extra_vars: context = dict(context.items() + extra_vars.items()) submission = self.save_submission(sms, submission_status, instance_fields, sub_type=sub_type, context=context) # Remote server calls r_answer = submission.remote_process_submission() if r_answer: answer = r_answer else: if not answer: answer = self.process_answer_template(default_answer, context) processed_answer = self.process_answer_template(answer, context) if return_submission: return processed_answer, submission else: return processed_answer
def __init__(self, file_name): DataFile.__init__(self, file_name) result_file_info = self._get_file_info() self.topic = Topic.create_or_update( result_file_info['topic_id'] ) self.user = User.create_or_update( result_file_info['user_id'] ) self.condition = Condition.create_or_update( result_file_info['condition'] ) self.__create_or_update_session() self.query = Query.create_or_update( result_file_info['query_id'], topic = self.topic, user = self.user, session = self.session ) self.actions = self.__parse() self.topic.add_actions( self.actions ) self.user.add_actions( self.actions ) self.query.add_actions( self.actions ) self.session.add_actions( self.actions ) self.session.add_query( self.query )
def __init__(self, rule_id, from_json=None): self.id = rule_id if from_json is None: from_json = {} self.scope = from_json.get('scope') self.name = from_json.get('name') self.description = from_json.get('description') self.references = from_json.get('references', []) cond_dict = from_json.get('condition') self.condition = Condition(cond_dict) if 'subject' in cond_dict else ConditionSet(cond_dict) action_dict = from_json.get('actions') self.actions = Action.from_array(action_dict) self.last_results = None
def has_class(self, class_name): return Condition(lambda x: class_name in self.classes)
def is_not_selected(self): return Condition(ec.element_selection_state_to_be(self.element, False), self._scope)
def is_clickable(self): return Condition(ec.element_to_be_clickable(self.locator), self._scope)
def is_visible(self): return Condition(ec.visibility_of(self.element), self._scope)
def is_present(self): return Condition(ec.presence_of_element_located(self.locator), self._scope)
def alert_is_present(self): return Condition(ec.alert_is_present(), self.driver)
def weather(self, location, num_of_days=2, date='today'): """ Try to get forecast for given location. Location pass one of the following: City and Town name Acceptable formats are: City Name City Name, State (US only) City Name, State, Country City Name, Country e.g.: q=New+York or q=New+york,ny or q=London,united+kingdom IP address e.g.: q=101.25.32.325 UK or Canada Postal Code or US Zipcode e.g.: q=SW1 or q=90201 Latitude,Longitude (in decimal degree) e.g.: q=48.834,2.394 Return current condition as :class:`Weather` and forecast as list of :class:`Weather` """ path = 'weather' if isinstance(location, City): location = '{0},{1},{2}'.format(location.areaName, location.region, location.country) response = self.__request(path, { 'q':location, 'num_of_days':num_of_days, 'format':self.format, 'date':date, }) tree = ET.fromstring(response) if tree.find('error'): raise Exception(tree.find('error').find('msg').text) condition = Condition() for node in tree.find('current_condition').getchildren(): if node.tag == 'observation_time': utcnow = datetime.utcnow() source = '{0}-{1}-{2} '.format( utcnow.year, utcnow.month, utcnow.day ) + node.text date = datetime.strptime(source,'%Y-%m-%d %I:%M %p') condition.__setattr__(node.tag, date) continue condition.__setattr__(node.tag, node.text) forecast = list() for node in tree.findall('weather'): weather = Weather() for child in node.getchildren(): if child.tag == 'date': date = datetime.strptime(child.text,'%Y-%m-%d') weather.__setattr__(child.tag, date) continue weather.__setattr__(child.tag, child.text) forecast.append(weather) return condition, forecast
def run_test2_steps(self): """ Complete: True Consistent: True Solution: True Linearization : start move b a table2 move a table0 table1 move d c table0 move c table4 table3 finish """ steps, ordering_constraints, causal_links = self.get_parameters( "test8") # TODO steps.append( Step(2, "move b a table2", [ Condition(True, "clear table2"), Condition(True, "on b a"), Condition(True, "clear b") ], [ Condition(True, "on b table2"), Condition(True, "clear a"), Condition(True, "clear a") ])) steps.append( Step(3, "move c table4 table3", [ Condition(True, "clear table3"), Condition(True, "on c table4"), Condition(True, "clear c") ], [ Condition(True, "clear table4"), Condition(True, "on c table3") ])) steps.append( Step(4, "move d c table0", [ Condition(True, "on d c"), Condition(True, "clear d"), Condition(True, "clear table0") ], [ Condition(True, "on d table0"), Condition(True, "clear c"), Condition(True, "clear c") ])) steps.append( Step(5, "move a table0 table1", [ Condition(True, "clear table1"), Condition(True, "on a table0"), Condition(True, "clear a") ], [ Condition(True, "clear table0"), Condition(True, "on a table1") ])) return steps, ordering_constraints, causal_links
def run_test1_steps(self): """ Complete: True Consistent: True Solution: True Linearization: start move b a table2 move c d table3 move c table3 b move a table0 table3 move d table6 table0 finish """ steps, ordering_constraints, causal_links = self.get_parameters( "test2") # TODO # fill in missing steps, e.g., steps.append(.....) steps.append( Step(2, "move c d table3", [ Condition(True, "clear c"), Condition(True, "clear table3"), Condition(True, "on d c") ], [Condition(True, "on c table3"), Condition(True, "clear d")])) steps.append( Step(3, "move c table3 b", [Condition(True, "clear c"), Condition(True, "clear b")], [ Condition(True, "clear table3"), Condition(True, "on a table0"), Condition(True, "on c b") ])) steps.append( Step(4, "move a table0 table3", [ Condition(True, "clear a"), Condition(True, "clear table3"), Condition(True, "on a table0") ], [ Condition(True, "clear table0"), Condition(True, "on a table3") ])) steps.append( Step(5, "move d table6 table0", [ Condition(True, "clear table0"), Condition(True, "on d table6"), Condition(True, "clear d") ], [ Condition(True, "on d table0"), Condition(True, "clear table6") ])) steps.append( Step(6, "move b a table2", [ Condition(True, "on b a"), Condition(True, "clear b"), Condition(True, "clear table2") ], [Condition(True, "clear a"), Condition(True, "on b table2")])) return steps, ordering_constraints, causal_links
class Rule(Matcher): """ A Rule A rule is a set of condition-sets, which can be nested and in turn contain other condition-sets or actual conditions. The rule itself has one top-level condition-set which is an "all" condition set. """ def __init__(self, rule_id, from_json=None): self.id = rule_id if from_json is None: from_json = {} self.scope = from_json.get('scope') self.name = from_json.get('name') self.description = from_json.get('description') self.references = from_json.get('references', []) cond_dict = from_json.get('condition') self.condition = Condition(cond_dict) if 'subject' in cond_dict else ConditionSet(cond_dict) action_dict = from_json.get('actions') self.actions = Action.from_array(action_dict) self.last_results = None def json(self): return json.dumps(self, cls=JSONRuleEncoder) @classmethod def load_rules(cls, record=None): """ Loads all bundled rules """ rules = [] old_results = None # get old results if record is not None: old_results = record.stored_rule_results # find all files starting with "rule-*.json" mydir = os.path.realpath(os.getcwd()) for rule_file in glob.glob('rules/rule-*.json'): rule_id_full = os.path.basename(rule_file) rule_id = rule_id_full.replace('.json', '').replace('rule-', '') # load the rule rule = cls._rule_from_file(rule_id, rule_file) if rule: rules.append(rule) # has it been run against the record before? if old_results is not None: rule.last_results = RuleResult.from_json_array(rule, old_results.get(rule.id)) return rules @classmethod def rule_named(cls, rule_name): """ Loads the given rule """ rule = None filepath = 'rules/rule-%s.json' % rule_name.replace('/', '') # if the file exists, load the rule if os.path.exists(filepath): rule = cls._rule_from_file(rule_name, filepath) return rule @classmethod def _rule_from_file(cls, rule_id, filepath): """ Load a rule from a given file. The file must exist, it is not checked! """ rule = None with open(filepath) as handle: rule_json = handle.read() rule = cls(rule_id, json.loads(rule_json)) return rule # -------------------------------------------------------------------------- Matching and Acting def match_against(self, record): """ Runs the rule, stores the run info on the server and returns a flag whether the rule did match. """ if record is None: raise Exception("Can not run rule %s without a record" % self.id) # run against record record.prepare_rule_run(self) flag = self.condition.match_against(record) results = record.matches_for(self) if flag else None # store this new result new_result = RuleResult(self, None, flag, results) record.store_new_result_for_rule(new_result, self) return flag def perform_actions(self, record): """ Returns an array of result actions """ results = [] for action in self.actions: result = action.execute_for(record) if result is not None: results.append(result) return results # -------------------------------------------------------------------------- Utilities def __unicode__(self): return '<rule.Rule %s>' % self.name def __str__(self): return unicode(self).encode('utf-8') def __repr__(self): return str(self)
from step import Step from condition import Condition from link import Link steps = [] steps.append( Step(0, "start", [], [ Condition(True, "on a table0"), Condition(True, "on d table6"), Condition(True, "on b a"), Condition(True, "on c d"), Condition(True, "clear b"), Condition(True, "clear c"), Condition(True, "clear table2"), Condition(True, "clear table3"), Condition(True, "clear table4") ])) steps.append( Step(1, "finish", [ Condition(True, "on d table0"), Condition(True, "on a table3"), Condition(True, "on b table2"), Condition(True, "on c b"), Condition(True, "clear table6") ], [])) causal_links = [] causal_links.append(Link(0, 6, Condition(True, "clear b"))) causal_links.append(Link(0, 6, Condition(True, "on b a"))) causal_links.append(Link(0, 6, Condition(True, "clear table2"))) causal_links.append(Link(0, 2, Condition(True, "clear c"))) causal_links.append(Link(0, 2, Condition(True, "on d c")))
from step import Step from condition import Condition from link import Link steps = [] steps.append(Step(0, "start", [], [Condition(True, "on a table0"), Condition(True, "on d a"), Condition(True, "on c d"), Condition(True, "on b table1"), Condition(True, "clear c"), Condition(True, "clear b"), Condition(True, "clear table2")])) steps.append(Step(1, "finish", [Condition(True, "on c table2"), Condition(True, "on d c"), Condition(True, "on b d"), Condition(True, "on a b"), Condition(True, "clear a"), Condition(True, "clear table0"), Condition(True, "clear table1")], [])) steps.append(Step(2, "move c d table2", [Condition(True, "on c d"), Condition(True, "clear c"), Condition(True, "clear table2")], [Condition(True, "clear d"), Condition(False, "clear table2"), Condition(True, "on c table2")])) steps.append(Step(3, "move d a c", [Condition(True, "on d a"), Condition(True, "clear d"), Condition(True, "clear c")], [Condition(True, "clear a"), Condition(True, "on d c"), Condition(False, "clear c")])) steps.append(Step(4, "move b table1 d", [Condition(True, "on b table1"), Condition(True, "clear b"), Condition(True, "clear d")], [Condition(True, "clear table1"), Condition(False, "clear d"), Condition(True, "on b d")])) steps.append(Step(5, "move a table0 b", [Condition(True, "on a table0"), Condition(True, "clear a"), Condition(True, "clear b")], [Condition(True, "clear table0"), Condition(False, "clear b"), Condition(True, "on a b")])) ordering_constraints = [] ordering_constraints.append([0, 1, 2, 3, 4, 5]) ordering_constraints.append([2, 1, 3, 4, 5]) ordering_constraints.append([3, 1, 4, 5]) ordering_constraints.append([4, 1, 5]) ordering_constraints.append([5, 1]) causal_links = [] causal_links.append(Link(2, 1, Condition(True, "on c table2"))) causal_links.append(Link(3, 1, Condition(True, "on d c"))) causal_links.append(Link(4, 1, Condition(True, "on b d"))) causal_links.append(Link(5, 1, Condition(True, "on a b"))) causal_links.append(Link(3, 1, Condition(True, "clear a"))) causal_links.append(Link(5, 1, Condition(True, "clear table0"))) causal_links.append(Link(4, 1, Condition(True, "clear table1"))) causal_links.append(Link(0, 2, Condition(True, "on c d"))) causal_links.append(Link(0, 2, Condition(True, "clear c"))) causal_links.append(Link(0, 2, Condition(True, "clear table2"))) causal_links.append(Link(0, 3, Condition(True, "on d a")))
def setUp(self): self.condition = Condition("Condition1", [], "name", -1, 0) self.symptom = Symptom("name", 0, 0, [self.condition], [], "description")
def p(x): return x def q(x): return -1 def f(x): return 0 y, z, x = sympy.symbols('y,z,x') section = [0, 1] count_point = 5 step = (section[1] - section[0]) / count_point alpha, betta, y_0 = 1, 0, 1 delta, gamma, y_1 = 2, 1, 0 cond_a = Condition(alpha, betta, y_0, TYPE_A, y, z) cond_b = Condition(delta, gamma, y_1, TYPE_B, y, z) parametrs_method = { 'step': step, 'section': section, } method = FiniteDifferenceMethod(**parametrs_method) parametrs_solve = { 'p': p, 'f': f, 'q': q, 'cond_a': cond_a, 'cond_b': cond_b, 'x': x, 'y': y
def run_test1_causal_links(self): """ Complete: True Consistent: True Solution: True Linearization: Start move a b table1 move b table0 a Finish """ steps, ordering_constraints, causal_links = self.get_parameters( "test3") # TODO # fill in missing causal_links, e.g., causal_links.append(.....) causal_links.append(Link(0, 3, Condition(True, "clear a"))) causal_links.append(Link(0, 3, Condition(True, "on b table0"))) causal_links.append(Link(0, 2, Condition(True, "clear table1"))) causal_links.append(Link(0, 2, Condition(True, "clear a"))) causal_links.append(Link(0, 2, Condition(True, "on a b"))) causal_links.append(Link(2, 3, Condition(True, "clear a"))) causal_links.append(Link(2, 3, Condition(True, "on b table0"))) causal_links.append(Link(2, 3, Condition(True, "clear b"))) causal_links.append(Link(2, 1, Condition(True, "clear b"))) causal_links.append(Link(3, 1, Condition(True, "on b a"))) causal_links.append(Link(3, 1, Condition(True, "clear b"))) return steps, ordering_constraints, causal_links
def process_confirmation_conditions(self, message): """Processa as condições em caso de mensagem de confirmação de envio""" return Condition.process_conditions(self.confirmation_conditions.all(), message)
def run_test2_causal_links(self): """ Complete: True Consistent: True Solution: True Linearization: start move a b table2 move b table0 c move a table2 b finish """ steps, ordering_constraints, causal_links = self.get_parameters( "test19") # TODO # fill in missing causal_links, e.g., causal_links.append(.....) causal_links.append(Link(0, 1, Condition(True, "on c d"))) causal_links.append(Link(0, 1, Condition(True, "on d table1"))) causal_links.append(Link(0, 1, Condition(True, "clear a"))) causal_links.append(Link(0, 3, Condition(True, "on a b"))) causal_links.append(Link(0, 3, Condition(True, "clear a"))) causal_links.append(Link(0, 3, Condition(True, "clear table2"))) causal_links.append(Link(0, 4, Condition(True, "on b table0"))) causal_links.append(Link(0, 4, Condition(True, "clear c"))) causal_links.append(Link(3, 4, Condition(True, "clear b"))) causal_links.append(Link(3, 5, Condition(True, "on a table2"))) causal_links.append(Link(3, 5, Condition(True, "clear b"))) causal_links.append(Link(4, 1, Condition(True, "on b c"))) causal_links.append(Link(4, 1, Condition(True, "clear table0"))) causal_links.append(Link(5, 1, Condition(True, "on a b"))) causal_links.append(Link(5, 1, Condition(True, "clear table2"))) return steps, ordering_constraints, causal_links
def test_add_preexisting_condition(self): cond = Condition("Runny nose and sneezing", [], "flu", 19283, 0) self.assertEqual([], self.user.getPreExistingConditions()) self.user.addPreExistingCondition(cond) self.assertEqual(cond, self.user.getPreExistingConditions()[0])
from step import Step from condition import Condition from link import Link steps = [] steps.append(Step(0, "start", [], [Condition(True, "on e table3"), Condition(True, "on a b"), Condition(True, "on b table0"), Condition(True, "on c d"), Condition(True, "on d table1"), Condition(True, "clear a"), Condition(True, "clear c"), Condition(True, "clear table2")])) steps.append(Step(1, "finish", [Condition(True, "on e table2"), Condition(True, "on a b"), Condition(True, "on b c"), Condition(True, "on c d"), Condition(True, "on d table1"), Condition(True, "clear a"), Condition(True, "clear table0")], [])) steps.append(Step(3, "move a b table2", [Condition(True, "on a b"), Condition(True, "clear a"), Condition(True, "clear table2")], [Condition(True, "on a table2"), Condition(True, "clear b"), Condition(False, "clear table2"), Condition(False, "on a b")])) steps.append(Step(4, "move b table0 c", [Condition(True, "on b table0"), Condition(True, "clear c"),Condition(True, "clear b")], [Condition(True, "on b c"), Condition(True, "clear table0"), Condition(False, "clear c")])) steps.append(Step(5, "move a table2 b", [Condition(True, "clear b"), Condition(True, "on a table2")], [Condition(True, "on a b"), Condition(False, "clear b"), Condition(True, "clear table2")])) steps.append(Step(6, "move e table3 table2", [Condition(True, "on e table3"),Condition(True, "clear table2")], [Condition(True, "on e table2")])) ordering_constraints = [] ordering_constraints.append([5, 6]) causal_links = [] causal_links.append(Link(0, 3, Condition(True, "on a b"))) causal_links.append(Link(0, 3, Condition(True, "clear a"))) causal_links.append(Link(0, 3, Condition(True, "clear table2"))) causal_links.append(Link(0, 4, Condition(True, "on b table0"))) causal_links.append(Link(0, 4, Condition(True, "clear c"))) causal_links.append(Link(3, 4, Condition(True, "clear b"))) causal_links.append(Link(3, 5, Condition(True, "clear b"))) causal_links.append(Link(3, 5, Condition(True, "on a table2"))) causal_links.append(Link(5, 1, Condition(True, "on a b"))) causal_links.append(Link(4, 1, Condition(True, "on b c"))) causal_links.append(Link(0, 1, Condition(True, "on c d"))) causal_links.append(Link(0, 1, Condition(True, "on d table1"))) causal_links.append(Link(0, 1, Condition(True, "clear a"))) causal_links.append(Link(4, 1, Condition(True, "clear table0"))) causal_links.append(Link(0, 6, Condition(True, "clear table2"))) causal_links.append(Link(0, 6, Condition(True, "on e table3"))) causal_links.append(Link(6, 1, Condition(True, "on e table2")))
def new_window_is_opened(self, current_handles=None): return Condition( ec.new_window_is_opened(current_handles or self.driver.window_handles), self.driver)
from step import Step from condition import Condition from link import Link steps = [] steps.append( Step(0, "start", [], [ Condition(True, "on a b"), Condition(True, "on b table0"), Condition(True, "on c d"), Condition(True, "on d table1"), Condition(True, "clear a"), Condition(True, "clear c"), Condition(True, "clear table2") ])) steps.append( Step(1, "finish", [ Condition(True, "on a b"), Condition(True, "on b c"), Condition(True, "on c d"), Condition(True, "on d table1"), Condition(True, "clear a"), Condition(True, "clear table0"), Condition(True, "clear table2") ], [])) steps.append( Step(3, "move a b table2", [ Condition(True, "on a b"), Condition(True, "clear a"), Condition(True, "clear table2") ], [
def is_stale(self): return Condition(ec.staleness_of(self.element), self._scope)
def __init__(self, json): self.temperature_unit = TemperatureUnit(json["units"]["temperature"]) self.condition = Condition(json["item"]["condition"]) self.location = Location(json["location"])
def is_invisible(self): return Condition(ec.invisibility_of_element(self.element), self._scope)
def do_GET(self): self._set_headers() if self.path.startswith('/?'): path = parse.urlparse(self.path[2:]).path path = parse.unquote_plus(path) entries = {} package = False for entry in path.split('&'): a = entry.split('=') if a[0] == 'extras[]': if 'package' in a[1]: package = True continue entries[a[0]] = a[1] if not a[1].isdecimal() else int(a[1]) conditions = Condition.create_conditions(entries) timestamp = datetime.now().strftime('%y%m%d_%H%M%S') log = open(timestamp + '.txt', 'w') log.write(pprint.pformat(conditions) + '\n') log.close() documents = Finder.find( Finder.get_collection('localhost', 27017, 'shoulie', 'resumes'), conditions) if package: Finder.package(documents, WebSvr.base_folder, timestamp + '.zip') message = Reporter.to_html(documents, '') """ html = open(timestamp + '.html', 'w') html.write(message) html.close() """ self.wfile.write(bytes(message, 'utf8')) elif self.path == '/' or self.path.endswith('.html'): path = parse.unquote(self.path.lstrip('/')) if not path: path = 'form.html' else: path = os.path.join(WebSvr.base_folder, path.split('_')[0], path) try: f = open(path) except FileNotFoundError: self.send_error(404, 'File Not Found: ' + path) return self.wfile.write(bytes(f.read(), 'utf8')) elif self.path.endswith('.docx'): path = parse.unquote(self.path.lstrip('/')) basic = os.path.splitext(path)[0] conditions = Condition.create_conditions({'file': basic + '.html'}) documents = Finder.find( Finder.get_collection('localhost', 27017, 'shoulie', 'resumes'), conditions) """ txt = open(basic + '.txt', 'w') txt.write(pprint.pformat(documents[0]) + '\n') txt.close() """ Saver.to_doc(documents[0], path) message = '''<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css">td, th {{ border: 1px solid black; }}</style> </head> <body> File "{}" generated </body> </html> ''' self.wfile.write(bytes(message.format(path), "utf8"))
def is_selected(self): return Condition(ec.element_to_be_selected(self.element), self._scope)
from step import Step from condition import Condition from link import Link steps = [] steps.append(Step(0,"start",[],[ Condition(True,"clear table4"), Condition(True, "clear table3"), Condition(True, "on c a"), Condition(True, "on b table0"), Condition(True, "on a table1"), Condition(True, "clear c"), Condition(True, "clear b")])) steps.append(Step(1,"finish",[Condition(True,"on a b"), Condition(True,"on b c")],[])) steps.append(Step(2,"move a table1 b",[Condition(True,"on a table1"), Condition(True,"clear b"), Condition(True,"clear a")],[ Condition(True,"on a b"), Condition(False, "on a table1"), Condition(True,"clear table1"), Condition(False, "clear b")])) steps.append(Step(3,"move b a c",[Condition(True,"on b a"), Condition(True,"clear c"), Condition(True,"clear b")],[ Condition(True,"on b c"), Condition(False, "on b a"), Condition(True,"clear a"), Condition(False, "clear c")])) steps.append(Step(4,"move b table0 a",[Condition(True,"on b table0"), Condition(True,"clear a"), Condition(True,"clear b")],[ Condition(True,"on b a"), Condition(False, "on b table0"), Condition(True,"clear table0"), Condition(False, "clear a")])) steps.append(Step(5,"move c a table4",[Condition(True,"on c a"), Condition(True,"clear table4"), Condition(True,"clear c")],[ Condition(True,"on c table4"), Condition(False, "on c a"), Condition(True,"clear a"), Condition(False, "clear table4")])) ordering_constraints = [] ordering_constraints.append([0,5,3,2,4,1]) ordering_constraints.append([1,3]) ordering_constraints.append([2,1]) ordering_constraints.append([3,2,1]) ordering_constraints.append([4,2,3,1]) ordering_constraints.append([5,3,2,4,1]) causal_links = [] causal_links.append(Link(0,5,Condition(True,"clear c"))) causal_links.append(Link(0,5,Condition(True,"clear table4"))) causal_links.append(Link(0,5,Condition(True,"on c a"))) causal_links.append(Link(0,4,Condition(True,"clear b"))) causal_links.append(Link(5,4,Condition(True,"clear a"))) causal_links.append(Link(0,4,Condition(True,"on b table0"))) causal_links.append(Link(0,3,Condition(True,"clear b"))) causal_links.append(Link(0,3,Condition(True,"clear c"))) causal_links.append(Link(4,3,Condition(True,"on b a"))) causal_links.append(Link(3,2,Condition(True,"clear a"))) causal_links.append(Link(0,2,Condition(True,"clear b"))) causal_links.append(Link(0,2,Condition(True,"on a table1"))) causal_links.append(Link(3,1,Condition(True,"on b c")))
def has_text(self, text): return Condition(ec.text_to_be_present_in_element(self.locator, text), self._scope)
def test_class_condition_not_satisfied_by_class_object(self): class A: pass isAnA = Condition(A) self.assertFalse(isAnA.matches(A))
from step import Step from condition import Condition from link import Link steps = [] steps.append( Step(0, "start", [], [ Condition(True, "clear table4"), Condition(True, "clear table3"), Condition(True, "on c a"), Condition(True, "on b table0"), Condition(True, "on a table1"), Condition(True, "clear c"), Condition(True, "clear b") ])) steps.append( Step(1, "finish", [Condition(True, "on a b"), Condition(True, "on b c")], [])) steps.append( Step(2, "move a table1 b", [ Condition(True, "on a table1"), Condition(True, "clear b"), Condition(True, "clear a") ], [ Condition(True, "on a b"), Condition(False, "on a table1"), Condition(True, "clear table1"), Condition(False, "clear b") ])) steps.append( Step(3, "move b a c", [ Condition(True, "on b a"),
def url_contains(self, url): return Condition(ec.url_contains(url), self.driver)
def test_value_condition_not_satisfied_by_other_value(self): is5 = Condition(5) self.assertFalse(is5.matches(7))
def url_matches(self, url_pattern): return Condition(ec.url_matches(url_pattern), self.driver)
def test_value_condition_satisfied_by_same_value(self): is5 = Condition(5) self.assertTrue(is5.matches(5))
def url_is(self, url): return Condition(ec.url_to_be(url), self.driver)
def url_changes(self): return Condition(ec.url_changes(self.driver.current_url), self.driver)
def test_function_condition_satisfied_when_function_returns_true(self): isEven = Condition(lambda number: number % 2 == 0) self.assertTrue(isEven.matches(4)) self.assertFalse(isEven.matches(3))