Exemplo n.º 1
0
def check_one_attribute(context, attr, name, value):

    context.cur_element = context.cur_group[name]
    cval = getattr(context.cur_element, attr)
    if cval != value:
        raise CAssertionError("Bad %s.%s = %r" % (name, attr, cval),
                              component=context.cur_element)
Exemplo n.º 2
0
def table_row_validate(context, key, val):
    table = context.cur_page['content']['table']
    header_cols = {comp.text: c for c, comp in table['head'].items()}

    cell = context.cur_row[header_cols[key]]
    if cell.text != val:
        raise CAssertionError("Row has %s=%r" % (key, cell.text),
                              component=cell)
Exemplo n.º 3
0
def names_of_items(context):
    expected = [r['Name'] for r in context.table]
    found = list(context.cur_group.items())

    while expected and found:
        ei = expected.pop(0)
        fi = found.pop(0)
        if fi[0] != ei:
            raise CAssertionError("Bad component \"%s\" instead of \"%s\"" %
                                  (fi[0], ei),
                                  component=fi[1])
    if expected:
        raise CAssertionError("Expected more components: %s" % expected,
                              component=fi[1])
    if found:
        raise CAssertionError("Found more components: %s" %
                              [f[0] for f in found],
                              component=found[0][1])
Exemplo n.º 4
0
def table_lookup(context, key, val):
    table = context.cur_page['content']['table']
    header_cols = {comp.text: c for c, comp in table['head'].items()}

    col_id = header_cols[key]
    for row in table['rows'].filter(lambda r: r[col_id].text == val):
        assert row[
            col_id].text == val, "Filter yields row: %s" % row.component_name
        context.cur_row = row
        break
    else:
        raise CAssertionError("No such row", component=table)
Exemplo n.º 5
0
def count_table(context):
    table = context.cur_page['content']['table']
    len_rows = len(table['rows'])
    if len_rows != context.num_rows:
        raise CAssertionError("Table has %d rows" % len_rows, component=table)
Exemplo n.º 6
0
def check_dialog_is_stale(context):
    try:
        list(context.cur_dialog.keys())
        raise CAssertionError("Can still read it", component=context.cur_dialog)
    except StaleElementReferenceException as e:
        pass
Exemplo n.º 7
0
def check_dialog_question(context, question):
    if context.cur_dialog.question != question:
        raise CAssertionError("Question is different",
                              component=context.cur_dialog)
Exemplo n.º 8
0
def check_payload(context, expected):
    if context.cur_element['payload'].text != expected:
        raise CAssertionError("Payload does not match!",
                              component=context.cur_element['payload'])
Exemplo n.º 9
0
def validate_long_text(context):
    with Fresh(context.cur_element):
        cur_value = context.cur_element['input'].value
        if cur_value != context.long_text:
            raise CAssertionError("Text differs",
                                  component=context.cur_element['input'])