def test_deserialize(self): connection_dump_1 = { 'connection_id': "mysql_default_1", 'conn_type': 'mysql', 'host': 'mysql', 'login': '******', 'schema': 'testschema', 'port': 80 } connection_dump_2 = { 'connection_id': "mysql_default_2" } result_1 = connection_collection_item_schema.load(connection_dump_1) result_2 = connection_collection_item_schema.load(connection_dump_2) self.assertEqual( result_1[0], { 'conn_id': "mysql_default_1", 'conn_type': 'mysql', 'host': 'mysql', 'login': '******', 'schema': 'testschema', 'port': 80 } ) self.assertEqual( result_2[0], { 'conn_id': "mysql_default_2", } )
def test_deserialize(self): connection_dump_1 = { 'connection_id': "mysql_default_1", 'conn_type': 'mysql', 'host': 'mysql', 'login': '******', 'schema': 'testschema', 'port': 80, } connection_dump_2 = { 'connection_id': "mysql_default_2", 'conn_type': "postgres", } result_1 = connection_collection_item_schema.load(connection_dump_1) result_2 = connection_collection_item_schema.load(connection_dump_2) assert result_1 == { 'conn_id': "mysql_default_1", 'conn_type': 'mysql', 'host': 'mysql', 'login': '******', 'schema': 'testschema', 'port': 80, } assert result_2 == { 'conn_id': "mysql_default_2", 'conn_type': "postgres", }
def test_deserialize_required_fields(self): connection_dump_1 = { 'connection_id': "mysql_default_2", } with self.assertRaisesRegex( marshmallow.exceptions.ValidationError, re.escape("{'conn_type': ['Missing data for required field.']}"), ): connection_collection_item_schema.load(connection_dump_1)