Exemplo n.º 1
0
 def test_update_product_explicit_name_different_from_constructed(
         self, get_conn):
     # Given
     update_product_method = get_conn.return_value.update_product
     update_product_method.return_value = None
     explicit_p_name = ProductSearchClient.product_path(
         PROJECT_ID_TEST_2, LOC_ID_TEST_2, PRODUCT_ID_TEST_2)
     product = Product(name=explicit_p_name)
     template_p_name = ProductSearchClient.product_path(
         PROJECT_ID_TEST, LOC_ID_TEST, PRODUCT_ID_TEST)
     # When
     # Location and product_id are passed in addition to a Product with an explicit name,
     # but both names differ (constructed != explicit).
     # Should throw AirflowException in this case.
     with self.assertRaises(AirflowException) as cm:
         self.hook.update_product(
             location=LOC_ID_TEST,
             product_id=PRODUCT_ID_TEST,
             product=product,
             update_mask=None,
             project_id=PROJECT_ID_TEST,
             retry=None,
             timeout=None,
             metadata=None,
         )
     err = cm.exception
     self.assertTrue(err)
     self.assertIn(
         ERR_DIFF_NAMES.format(explicit_name=explicit_p_name,
                               constructed_name=template_p_name,
                               label="Product",
                               id_label="product_id"),
         str(err),
     )
     update_product_method.assert_not_called()
Exemplo n.º 2
0
 def test_update_productset_explicit_name_different_from_constructed(self, get_conn):
     # Given
     update_product_set_method = get_conn.return_value.update_product_set
     update_product_set_method.return_value = None
     explicit_ps_name = ProductSearchClient.product_set_path(
         PROJECT_ID_TEST_2, LOC_ID_TEST_2, PRODUCTSET_ID_TEST_2
     )
     product_set = ProductSet(name=explicit_ps_name)
     template_ps_name = ProductSearchClient.product_set_path(
         PROJECT_ID_TEST, LOC_ID_TEST, PRODUCTSET_ID_TEST
     )
     # When
     # Location and product_set_id are passed in addition to a ProductSet with an explicit name,
     # but both names differ (constructed != explicit).
     # Should throw AirflowException in this case.
     with pytest.raises(AirflowException) as ctx:
         self.hook.update_product_set(
             location=LOC_ID_TEST,
             product_set_id=PRODUCTSET_ID_TEST,
             product_set=product_set,
             update_mask=None,
             project_id=PROJECT_ID_TEST,
             retry=None,
             timeout=None,
             metadata=None,
         )
     err = ctx.value
     # self.assertIn("The required parameter 'project_id' is missing", str(err))
     assert err
     assert (
         ERR_DIFF_NAMES.format(
             explicit_name=explicit_ps_name,
             constructed_name=template_ps_name,
             label="ProductSet",
             id_label="productset_id",
         )
         in str(err)
     )
     update_product_set_method.assert_not_called()