def test__update_content__log_location_and_subnet__fields_set(self):
     "AsiaqDataPipeline.update_content with log location and subnet ID"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     new_contents = [{
         'id':
         'Default',
         'fields': [{
             'key': 'uninteresting',
             'stringValue': 'thing'
         }],
         'name':
         'short'
     }, {
         'id': 'Other',
         'fields': [],
         'name': 'unused'
     }]
     pipeline.update_content(log_location='FAKEFAKE',
                             subnet_id='EVENFAKER',
                             contents=new_contents)
     self.assertIn({
         'key': 'pipelineLogUri',
         'stringValue': 'FAKEFAKE'
     }, pipeline._objects[0]['fields'])
     self.assertIn({
         'key': 'subnetId',
         'stringValue': 'EVENFAKER'
     }, pipeline._objects[0]['fields'])
 def test__update_content__no_values__content_updated(self):
     "AsiaqDataPipeline.update_content with no parameter values"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs)
     self.assertIs(pipeline._objects, pipeline_objects)
     self.assertIs(pipeline._params, param_defs)
     self.assertIsNone(pipeline._param_values)
 def test__update_content__no_values__content_updated(self):
     "AsiaqDataPipeline.update_content with no parameter values"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs)
     self.assertIs(pipeline._objects, pipeline_objects)
     self.assertIs(pipeline._params, param_defs)
     self.assertIsNone(pipeline._param_values)
 def test__update_content__log_location_and_subnet__fields_set(self):
     "AsiaqDataPipeline.update_content with log location and subnet ID"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     new_contents = [
         {'id': 'Default', 'fields': [{'key': 'uninteresting', 'stringValue': 'thing'}], 'name': 'short'},
         {'id': 'Other', 'fields': [], 'name': 'unused'}
     ]
     pipeline.update_content(log_location='FAKEFAKE', subnet_id='EVENFAKER', contents=new_contents)
     self.assertIn({'key': 'pipelineLogUri', 'stringValue': 'FAKEFAKE'}, pipeline._objects[0]['fields'])
     self.assertIn({'key': 'subnetId', 'stringValue': 'EVENFAKER'}, pipeline._objects[0]['fields'])
 def test__update_content__new_and_old_values__values_updated(self):
     "AsiaqDataPipeline.update_content overwrites parameter values when appropriate"
     orig_values = {'this': 'will', 'be': 'overwritten'}
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty", param_values=orig_values)
     new_values = {'foo': 'bar', 'baz': '1'}
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs, new_values)
     self.assertEqual([{'id': 'foo', 'stringValue': 'bar'}, {'id': 'baz', 'stringValue': '1'}],
                      pipeline._param_values)
 def test__update_content__old_values_new_empty__values_cleared(self):
     "AsiaqDataPipeline.update_content does not overwrite parameter values when not appropriate"
     orig_values = {'this': 'will', 'be': 'overwritten'}
     pipeline = AsiaqDataPipeline(name="asdf",
                                  description="qwerty",
                                  param_values=orig_values)
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs, [])
     self.assertEqual([], pipeline._param_values)
 def test__update_content__old_values_new_empty__values_cleared(self):
     "AsiaqDataPipeline.update_content does not overwrite parameter values when not appropriate"
     orig_values = {'this': 'will', 'be': 'overwritten'}
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty", param_values=orig_values)
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs, [])
     self.assertEqual(
         [],
         pipeline._param_values
     )
 def test__update_content__old_values_not_new_ones__values_unchanged(self):
     "AsiaqDataPipeline.update_content does not overwrite parameter values when not appropriate"
     orig_values = {'this': 'will not', 'be': 'overwritten'}
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty", param_values=orig_values)
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs)
     self.assertEqual(
         [{'id': 'this', 'stringValue': 'will not'}, {'id': 'be', 'stringValue': 'overwritten'}],
         pipeline._param_values
     )
 def test__update_content__dict_values__content_updated(self):
     "AsiaqDataPipeline.update_content with silly dictionary parameter values"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline_objects = Mock()
     param_defs = Mock()
     param_values = {'foo': 'bar', 'baz': '1'}
     pipeline.update_content(pipeline_objects, param_defs, param_values)
     self.assertIs(pipeline._objects, pipeline_objects)
     self.assertIs(pipeline._params, param_defs)
     self.assertEqual(2, len(pipeline._param_values))
     self.assertIs(list, type(pipeline._param_values))
     self.assertIn({'id': 'foo', 'stringValue': 'bar'}, pipeline._param_values)
     self.assertIn({'id': 'baz', 'stringValue': '1'}, pipeline._param_values)
     self.assertEqual({"foo": "bar", "baz": "1"}, pipeline.get_param_value_dict())
 def test__update_content__list_values__content_updated(self):
     "AsiaqDataPipeline.update_content with silly listed parameter values"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline_objects = Mock()
     param_defs = Mock()
     param_values = [
         {'id': 'foo', 'stringValue': 'bar'},
         {'id': 'bar', 'stringValue': 'baz'},
         {'id': 'simple', 'stringValue': 'string'}
     ]
     pipeline.update_content(pipeline_objects, param_defs, param_values)
     self.assertIs(pipeline._objects, pipeline_objects)
     self.assertIs(pipeline._params, param_defs)
     self.assertEqual(3, len(pipeline._param_values))
     self.assertEqual({"foo": "bar", "bar": "baz", "simple": "string"}, pipeline.get_param_value_dict())
 def test__update_content__old_values_not_new_ones__values_unchanged(self):
     "AsiaqDataPipeline.update_content does not overwrite parameter values when not appropriate"
     orig_values = {'this': 'will not', 'be': 'overwritten'}
     pipeline = AsiaqDataPipeline(name="asdf",
                                  description="qwerty",
                                  param_values=orig_values)
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs)
     self.assertEqual([{
         'id': 'this',
         'stringValue': 'will not'
     }, {
         'id': 'be',
         'stringValue': 'overwritten'
     }], pipeline._param_values)
 def test__update_content__new_and_old_values__values_updated(self):
     "AsiaqDataPipeline.update_content overwrites parameter values when appropriate"
     orig_values = {'this': 'will', 'be': 'overwritten'}
     pipeline = AsiaqDataPipeline(name="asdf",
                                  description="qwerty",
                                  param_values=orig_values)
     new_values = {'foo': 'bar', 'baz': '1'}
     pipeline_objects = Mock()
     param_defs = Mock()
     pipeline.update_content(pipeline_objects, param_defs, new_values)
     self.assertEqual([{
         'id': 'foo',
         'stringValue': 'bar'
     }, {
         'id': 'baz',
         'stringValue': '1'
     }], pipeline._param_values)
 def test__update_content__dict_values__content_updated(self):
     "AsiaqDataPipeline.update_content with silly dictionary parameter values"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline_objects = Mock()
     param_defs = Mock()
     param_values = {'foo': 'bar', 'baz': '1'}
     pipeline.update_content(pipeline_objects, param_defs, param_values)
     self.assertIs(pipeline._objects, pipeline_objects)
     self.assertIs(pipeline._params, param_defs)
     self.assertEqual(2, len(pipeline._param_values))
     self.assertIs(list, type(pipeline._param_values))
     self.assertIn({
         'id': 'foo',
         'stringValue': 'bar'
     }, pipeline._param_values)
     self.assertIn({
         'id': 'baz',
         'stringValue': '1'
     }, pipeline._param_values)
     self.assertEqual({
         "foo": "bar",
         "baz": "1"
     }, pipeline.get_param_value_dict())
 def test__update_content__list_values__content_updated(self):
     "AsiaqDataPipeline.update_content with silly listed parameter values"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline_objects = Mock()
     param_defs = Mock()
     param_values = [{
         'id': 'foo',
         'stringValue': 'bar'
     }, {
         'id': 'bar',
         'stringValue': 'baz'
     }, {
         'id': 'simple',
         'stringValue': 'string'
     }]
     pipeline.update_content(pipeline_objects, param_defs, param_values)
     self.assertIs(pipeline._objects, pipeline_objects)
     self.assertIs(pipeline._params, param_defs)
     self.assertEqual(3, len(pipeline._param_values))
     self.assertEqual({
         "foo": "bar",
         "bar": "baz",
         "simple": "string"
     }, pipeline.get_param_value_dict())
 def test__update_content__template__content_updated(self):
     "AsiaqDataPipeline.update_content with a template"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline.update_content(template_name="dynamodb_restore")
     self.assertTrue(pipeline.has_content())
     self.assertEqual("DDBDestinationTable", pipeline._objects[1]['id'])
 def test__update_content__template__content_updated(self):
     "AsiaqDataPipeline.update_content with a template"
     pipeline = AsiaqDataPipeline(name="asdf", description="qwerty")
     pipeline.update_content(template_name="dynamodb_restore")
     self.assertTrue(pipeline.has_content())
     self.assertEqual("DDBDestinationTable", pipeline._objects[1]['id'])