示例#1
0
    def testUnnest_NonExistingKey(self):
        [x1, x2, x3] = self.create_artifacts(uri_prefix='x/', n=3)
        input_dict = {'x': [x1, x2, x3]}

        with self.assertRaisesRegex(
                exceptions.FailedPreconditionError,
                'Input dict does not contain the key y.',
        ):
            test_utils.run_resolver_op(unnest_op.Unnest, input_dict, key='y')
示例#2
0
    def testUnnest_EmptyChannel_ReturnsEmptyList(self):
        input_dict = {'x': []}

        result = test_utils.run_resolver_op(unnest_op.Unnest,
                                            input_dict,
                                            key='x')

        self.assertEmpty(result)
示例#3
0
    def testUnnest_KeyChannel_Unnested(self):
        [x1, x2, x3] = self.create_artifacts(uri_prefix='x/', n=3)
        input_dict = {'x': [x1, x2, x3]}

        result = test_utils.run_resolver_op(unnest_op.Unnest,
                                            input_dict,
                                            key='x')

        self.assertEqual(result, [{'x': [x1]}, {'x': [x2]}, {'x': [x3]}])
示例#4
0
    def testUnnest_NonKeyChannel_IsNotUnnested(self):
        [x1, x2, x3] = self.create_artifacts(uri_prefix='x/', n=3)
        ys = self.create_artifacts(uri_prefix='y/', n=2)
        input_dict = {'x': [x1, x2, x3], 'y': ys}

        result = test_utils.run_resolver_op(unnest_op.Unnest,
                                            input_dict,
                                            key='x')

        self.assertEqual(result, [
            {
                'x': [x1],
                'y': ys
            },
            {
                'x': [x2],
                'y': ys
            },
            {
                'x': [x3],
                'y': ys
            },
        ])
示例#5
0
  def testSkipIfEmpty_OnNonEmpty_ReturnsAsIs(self):
    x1, x2, x3 = self.create_artifacts(uri_prefix='x/', n=3)
    input_dicts = [{'x': [x1]}, {'x': [x2]}, {'x': [x3]}]

    result = test_utils.run_resolver_op(SkipIfEmpty, input_dicts)
    self.assertEqual(result, [{'x': [x1]}, {'x': [x2]}, {'x': [x3]}])
示例#6
0
 def testSkipIfEmpty_OnEmpty_RaisesSkipSignal(self):
   with self.assertRaises(exceptions.SkipSignal):
     test_utils.run_resolver_op(SkipIfEmpty, [])