2

Imagine a product that gives you a webpage with a list of all files in a folder. The list specifies file name and age (6 months old, 1 year old...).

There's an automated test that refers the Meter to a canned folder, where file names and age are known. The test has the names and age hardcoded in the test script.

Of course, as time moves on, files age and the hardcoded expected age values are no longer correct.

I've thought about a few options:

1. Create a script that changes the metadata of the files to conform with the expected ages, so the test passes.
* The obvious problem being that if the age meter is broken and always returning the same values, the test will fail to detect that!
* Another problem is that this script will have to track hundreds of files... It will be a lot of boring work to write it!

4. Create a script that reads the actual file ages and updates that into a list of parameters that the test reads (it will no longer be hardcoded). The script would log file names and ages recursively, so no need to track the files.
* This has the problem that, with time, all files will fall into a certain age group, not testing other age groups.
* Also a problem that the test then drills in to a specific file in a specific age group, for validating the further analysis. If that file had moved, the test won't be able to get to it.

Unfortunately, the "file age meter" product does extended analysis on the files, trying to find keywords in them (also hardcoded). So, the solution doesn't seem to be: "script that creates random files in a known age group distribution and then test just aggregates the numbers"

1 Answer 1

2

I would create a test folder where file name matches file date. Then, it is easy (using a script) to check that files returned by date match the desired date (based on the current date, and data arithmetic). Python has very flexible timedelta object, perfect match for this.

Of course every day different files will fell into every age group, but if file names match the file creating dates, you don't have to recreate them again.

Or if you want to be more fancy: you can create for every test bunch of files with desired "date created/modified", and wipe them afterwards:

How to change "modified time

2
  • Maybe I am missing your point... but I think you missed mine :) The Age Meter functionality checks the AGE of the file, not the creation date. It also groups and tallies files by age. Result of this functionality would be something like: "you have 10 files of 1 year age, 20 files of 2 year age...". I just don't understand how your answer helps me (sorry, I am not very smart!)
    – DraxDomax
    Jan 4, 2018 at 11:53
  • Yes, you are missing the point. If you know the today's date, and date of the file creation, it is not that hard to calculate file's age, is it? Jan 4, 2018 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.