def test_update_chart_document_keys_not_removed_with_override(self): with open(self.base_manifest) as f: documents = list(yaml.safe_load_all(f.read())) documents_modified = copy.deepcopy(documents) del documents_modified[0]['data']['chart_name'] # verify both doc have different values for data self.assertNotEqual(documents[0], documents_modified[0]) ovr = Override(documents) # update with document values with the modified ones ovr.update_chart_document(documents_modified[0]) self.assertIn('chart_name', ovr.documents[0]['data']) self.assertNotEqual(ovr.documents[0], documents_modified[0])
def test_update_chart_document_valid(self): with open(self.base_manifest) as f: documents = list(yaml.safe_load_all(f.read())) documents_modified = copy.deepcopy(documents) # Case 1: Checking if primitives get updated documents_modified[0]['data']['chart_name'] = 'modified' # starting out, both doc have different values for data self.assertNotEqual(documents[0], documents_modified[0]) ovr = Override(documents) # update with document values with the modified ones ovr.update_chart_document(documents_modified[0]) # after the update, both documents are equal self.assertEqual(ovr.documents[0]['data']['chart_name'], documents_modified[0]['data']['chart_name']) self.assertEqual(ovr.documents[0], documents_modified[0]) # Case 2: Checking if dictionaries get updated documents_modified[0]['data']['values'] = {'foo': 'bar'} ovr.update_chart_document(documents_modified[0]) # after the update, both documents are equal self.assertEqual(ovr.documents[0]['data']['values'], documents_modified[0]['data']['values']) self.assertEqual(ovr.documents[0], documents_modified[0]) # Case 3: Checking if lists get updated documents_modified[0]['data']['dependencies'] = ['foo', 'bar'] ovr.update_chart_document(documents_modified[0]) # after the update, both documents are equal self.assertEqual(['foo', 'bar'], ovr.documents[0]['data']['dependencies']) self.assertEqual(documents_modified[0]['data']['dependencies'], ovr.documents[0]['data']['dependencies']) self.assertEqual(ovr.documents[0], documents_modified[0])