Originally, I was just assuming there’d be a data set and a CSL file for
each test, and I’d have to format the data by hand, although this approach
doesn’t scale very well if we decide we need more than 5-10 test cases.
Same here. Plus, I don’t quite consider the scaling very problematic.
Put differently, why would you not create objects?
Well, to be exact, I do actually use objects, only these are not by
own custom objects, but of class Element (from xml.dom.minidom). The
reason I chose this was that especially RDF and MODS store stuff in a
hierarchical manner (you know this right, Bruce? ;-)). I would have to
invent a way to do that in a custom object too in order not too lose
data. I didn’t quite felt like inventing an object that could combine
RDF and MODS because I felt it was quite hard to do.
Right now my code just simply uses a method to fetch the data by
asking a method for it. “I need to know for this reference what the
author is (provide it to me according to this options)” (that is this
function: dataForMatch(self, match, keyElement, useEtAlStyle,
biblioref=None)) (will probably rename this function to
dataForRDFMatch)
This function is pretty straightforward, and if I want to support
another storage format, I only need to change it (perhaps name the
method something like dataForModsMatch).
OK, but you are assuming files then. What happens if you change your
mind and want to store the data in an SQL database? Or the XML source
changes? Isn’t it easier to just change some input code and keep the
internal stuff constant?
Of course I could write a dataForSQLMatch that queries data whenever
it is asked for (with some caching obviously). My input code is in the
dataFor…Match function.
That’s a possibility. My only concern about that is that what are you
testing then: the citation processing, or the input code?
It’s not very hard to see where it goes wrong usually. Plus, shouldn’t
both be tested anyway?
Johan