Skip to content

Commit

Permalink
Correct the ScriptRepositoryTest to not change the properties
Browse files Browse the repository at this point in the history
When the unittest is executed it should not change the configured user property.
Add also a new unit test to ensure that folder has correct status after download.

re #6177
  • Loading branch information
gesnerpassos committed Apr 18, 2013
1 parent 3c0b70d commit fd11b9f
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <algorithm>
#include <Poco/DateTimeFormatter.h>
#include <boost/algorithm/string.hpp>
#include "MantidKernel/ConfigService.h"
using Mantid::Kernel::ConfigService;
using Mantid::Kernel::ConfigServiceImpl;
using namespace std;
using Mantid::API::ScriptRepositoryImpl;
using Mantid::API::ScriptRepoException;
Expand Down Expand Up @@ -184,12 +187,15 @@ ctest -j8 -R ScriptRepositoryTestImpl_ --verbose
class ScriptRepositoryTestImpl : public CxxTest::TestSuite{
ScriptRepositoryImplLocal * repo;
std::string local_rep;
std::string backup_local_repository_path;
public:
static ScriptRepositoryTestImpl * createSuite(){return new ScriptRepositoryTestImpl(); }
static void destroySuite (ScriptRepositoryTestImpl * suite){delete suite; }

// ensure that all tests will be perfomed in a fresh repository
void setUp(){
void setUp(){
ConfigServiceImpl & config = ConfigService::Instance();
backup_local_repository_path = config.getString("ScriptLocalRepository");
local_rep = std::string(Poco::Path::current()).append("mytemprepository/");
TS_ASSERT_THROWS_NOTHING(repo = new ScriptRepositoryImplLocal(local_rep, webserverurl));
}
Expand All @@ -203,6 +209,9 @@ class ScriptRepositoryTestImpl : public CxxTest::TestSuite{
}catch(Poco::Exception & ex){
TS_WARN(ex.displayText());
}
ConfigServiceImpl & config = ConfigService::Instance();
config.setString("ScriptLocalRepository", backup_local_repository_path);
config.saveConfig(config.getUserFilename());
}


Expand Down Expand Up @@ -547,6 +556,24 @@ class ScriptRepositoryTestImpl : public CxxTest::TestSuite{
TS_ASSERT(repo->fileStatus(dir_name) == Mantid::API::BOTH_CHANGED);
}

/*************************************
* FILE STATUS
*************************************/
void test_info_of_downloaded_folder(){
std::string file_name = "TofConv/TofConverter.py";
std::string folder_name = "TofConv";
// install
TS_ASSERT_THROWS_NOTHING(repo->install(local_rep));
// list files
TS_ASSERT_THROWS_NOTHING(repo->listFiles());
// download
TS_ASSERT_THROWS_NOTHING(repo->download(folder_name));
// it must be unchanged
TS_ASSERT(repo->fileStatus(file_name) == Mantid::API::BOTH_UNCHANGED) ;
// it
TS_ASSERT(repo->fileStatus(folder_name) == Mantid::API::BOTH_UNCHANGED) ;
}

void test_downloading_and_removing_files(){
std::string file_name = "TofConv/TofConverter.py";
// install
Expand Down

0 comments on commit fd11b9f

Please sign in to comment.