Ejemplo n.º 1
0
def step_impl(context):
    expected_locations = [row['name'] for row in context.table]

    feed = get_locations_by_type(*EXPORTABLE)
    actual_locations = [location.name for location in feed.entries]
    
    assert_that(actual_locations, contains_inanyorder(*expected_locations))
Ejemplo n.º 2
0
def step_impl(context):
    model = context.model
    actuals = dbt_run_sql(context, 'select * from {{ref("' + model + '")}}')
    context.query_result = actuals
    expected = behave2agate(context.table)
    assert_that(actuals.column_names, equal_to(expected.column_names))
    assert_that([r.values() for r in actuals.rows],
                contains_inanyorder(*[r.values() for r in expected.rows]))
Ejemplo n.º 3
0
def step_1(context, department):
    """
    Compares expected with actual persons in a department.
    NOTE: Unordered comparison (ordering is not important).
    """
    department_ = context.model.departments.get(department, None)
    if not department_:
        assert_that(False, "Department %s is unknown" % department)
    # -- NORMAl-CASE:
    expected_persons = [ row["name"]    for row in context.table ]
    actual_persons   = department_.members

    # -- UNORDERED TABLE-COMPARISON (using: pyhamcrest)
    assert_that(contains_inanyorder(*expected_persons), actual_persons)
Ejemplo n.º 4
0
def step_impl(context, department):
    """
    Compares expected with actual persons in a department.
    NOTE: Unordered comparison (ordering is not important).
    """
    department_ = context.model.departments.get(department, None)
    if not department_:
        assert_that(False, "Department %s is unknown" % department)
    # -- NORMAl-CASE:
    expected_persons = [row["name"] for row in context.table]
    actual_persons = department_.members

    # -- UNORDERED TABLE-COMPARISON (using: pyhamcrest)
    assert_that(contains_inanyorder(*expected_persons), actual_persons)
Ejemplo n.º 5
0
def step_impl(context, entry_id):
    expected_jobs = [
        {key: int(row[key]) if key.endswith('_id') else row[key]
         for key in context.table.headings}
        for row in context.table 
    ]

    actual_jobs = [
        dict(
            entry_id = job.entry.id if job.entry is not None else None,
            location = job.location.name if job.location is not None else None,
            path = job.metadata.path if job.metadata is not None else None,
            user = get_user_by_id(job.user_id).name,
        )
        for job in get_export_jobs_by_entry_id(entry_id).entries
    ]

    print(get_export_jobs_by_entry_id(entry_id).to_json())
    assert_that(actual_jobs, contains_inanyorder(*expected_jobs))
 def testDoesNotMatchWithFewerElementsThanExpected(self):
     self.assert_mismatch_description(
         "no item matches: <4> in [<1>, <2>, <3>]",
         contains_inanyorder(1, 2, 3, 4),
         self._sequence(1, 2, 3),
     )
 def testDoesNotMatchWithMoreElementsThanExpected(self):
     self.assert_mismatch_description("not matched: <2>",
                                      contains_inanyorder(1, 3),
                                      self._sequence(1, 2, 3))
 def testDoesNotMatchIfOneOfMultipleItemsMismatch(self):
     self.assert_mismatch_description("not matched: <4>",
                                      contains_inanyorder(1, 2, 3),
                                      self._sequence(1, 2, 4))
 def testEmptySequenceMatchesEmptySequence(self):
     self.assert_matches("Empty sequence", contains_inanyorder(),
                         self._sequence())
 def testDescribeMismatchAfterMatch(self):
     matcher = contains_inanyorder(1, 2, 3)
     matcher.matches(self._sequence(3, 1))
     self.assert_describe_mismatch("no item matches: <2> in [<3>, <1>]",
                                   matcher, self._sequence(3, 1))
 def testDescribeMismatch(self):
     self.assert_describe_mismatch("not matched: <3>",
                                   contains_inanyorder(1, 2),
                                   self._sequence(1, 3))
 def testMatchesSequenceInOrder(self):
     self.assert_matches("In order",
                         contains_inanyorder(equal_to(1), equal_to(2)),
                         self._sequence(1, 2))
 def testMatchingSingleItemSequence(self):
     self.assert_matches("Single item sequence",
                         contains_inanyorder(equal_to(1)),
                         self._sequence(1))
Ejemplo n.º 14
0
def step_impl(context, department):
    expected_persons = [row["name"] for row in context.table]
    actual_persons = context.res.values()

    assert_that(contains_inanyorder(*expected_persons), actual_persons)
def step_impl(context):
    expected_result = [row["BearingList"] for row in context.table]
    opts_list = context.driver.find_elements_by_xpath(
        "//mat-option[contains(@id,'mat-option')]")
    actual_result = [opt.text for opt in opts_list]
    assert_that(expected_result, contains_inanyorder(*actual_result))
 def testMatchesAnyConformingSequence(self):
     self.assert_matches("quasi-sequence", contains_inanyorder(1, 2),
                         QuasiSequence())
     self.assert_does_not_match("non-sequence", contains_inanyorder(1, 2),
                                object())
 def testHasAReadableDescription(self):
     self.assert_description("a sequence over [<1>, <2>] in any order",
                             contains_inanyorder(1, 2))
 def testMatchesSequenceOutOfOrder(self):
     self.assert_matches("Out of order",
                         contains_inanyorder(equal_to(1), equal_to(2)),
                         self._sequence(2, 1))
 def testDescribeMismatchOfNonSequence(self):
     self.assert_describe_mismatch("was <3>", contains_inanyorder(1, 2), 3)
 def testProvidesConvenientShortcutForMatchingWithEqualTo(self):
     self.assert_matches(
         "Values automatically wrapped with equal_to",
         contains_inanyorder(1, 2),
         self._sequence(2, 1),
     )
 def testDoesNotMatchEmptySequence(self):
     self.assert_mismatch_description("no item matches: <1>, <2> in []",
                                      contains_inanyorder(1, 2),
                                      self._sequence())
Ejemplo n.º 22
0
def step_impl(context):
    expected = behave2agate(context.table)
    actuals = context.query_result
    assert_that(actuals.column_names, equal_to(expected.column_names))
    assert_that([r.values() for r in actuals.rows],
                contains_inanyorder(*[r.values() for r in expected.rows]))