OpenRA / OpenRA-Resources

The OpenRA Resource Center helps the community sharing their custom maps.
http://resource.openra.net
Other
21 stars 18 forks source link

Updates to allow for testing seeder without writing to data folder #385

Closed dsimmons87 closed 1 year ago

dsimmons87 commented 1 year ago

Adds the following:

Dependency Injection:

This package allows for making some defined modules and classes to be hot-swappable, which will aid with testing and upgrading, and also help make the code more modular.

It also allows for function arguments to be automatically pulled from its containers, but this doesn't work in python 3.5, so that will need to wait until python is updated.

Edit: As the server is now running python 3.7, I've change this now to inject the dependencies in the couple of places that the filesystem is used so far.

FS:

The FS module has several different implementations of a base FS structure, which makes it easy to swap out the OS file system for one in memory for testing for example. It also allows for Zips to be accessed and treated almost the same way as other parts of the file system so that may come in useful later.

Updates to process_upload in handlers.php:

I've swapped out some of the direct file system operations with some which use the FS module served from the service container. This allowed for the FS to be hot-swapped in the seeder test.

For now I've just manually tested it on the RC, but I'm hoping to break this code out into a more testable structure later.