<commit_before>#include "gtest/gtest.h"
#include "world/ComponentManager.h"
#include "world/system_setup.h"
#include "config/Config.h"
#include "iocontroller/IOController.h"

#include <thread>
#include <chrono>

#include "webstack/HttpClient.h"
#include "util/ComponentTest.h"

class HttpServerTest : public ComponentTest {
protected:
	Susi::IOController io;
	virtual void SetUp() override {
		io.makeDir(base_path+"/assets");
		io.writeFile(base_path+"/assets/test.txt","foobar");
		componentManager->startComponent("httpserver");
		std::this_thread::sleep_for(std::chrono::milliseconds{150});
	}
	virtual void TearDown() override {
		componentManager->stopAll();
	}

	virtual void GoodCases() override {

	}
	virtual void BadCases() override {
		
	}
	virtual void EdgeCases() override {
		
	}

};

TEST_F(HttpServerTest, GetAsset) {

	Susi::HttpClient client("http://[::1]:8080");

	auto body = client.get("/assets/test.txt");

	std::cout<<"Status: "<<client.getStatus()<<std::endl;
	std::cout<<"Body: "<<body<<std::endl;

	EXPECT_EQ("foobar",body);<commit_msg>["HttpServerTest] added more tests;<commit_after>#include "gtest/gtest.h"
#include "world/ComponentManager.h"
#include "world/system_setup.h"
#include "config/Config.h"
#include "iocontroller/IOController.h"

#include <thread>
#include <chrono>

#include "webstack/HttpClient.h"
#include "util/ComponentTest.h"

class HttpServerTest : public ComponentTest {
protected:
	Susi::IOController io;
	int status;
	virtual void SetUp() override {
		io.makeDir(base_path+"/assets");
		io.writeFile(base_path+"/assets/test.txt","foobar");
		io.writeFile(base_path+"/assets/test.svg", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
		componentManager->startComponent("httpserver");
		std::this_thread::sleep_for(std::chrono::milliseconds{150});
	}
	virtual void TearDown() override {
		componentManager->stopAll();
	}

	virtual void GoodCases() override {

	}
	virtual void BadCases() override {
		
	}
	virtual void EdgeCases() override {
		
	}

};

TEST_F(HttpServerTest, GetAsset) {

	Susi::HttpClient client("http://[::1]:8080");

	auto body = client.get("/assets/test.txt");
	int status = client.getStatus();

	//std::cout<<"Status: "<<status<<std::endl;
	//std::cout<<"Body: "<<body<<std::endl;

	EXPECT_EQ(200,status);
	EXPECT_EQ("foobar",body);
}

TEST_F(HttpServerTest, GetSVGAsset) {

	Susi::HttpClient client("http://[::1]:8080");

	auto body = client.get("/assets/test.svg");
	int status = client.getStatus();

	//std::cout<<"Status: "<<status<<std::endl;
	//std::cout<<"Body: "<<body<<std::endl;

	EXPECT_EQ(200,status);
	EXPECT_EQ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",body);
}

TEST_F(HttpServerTest, GetMissingAsset) {

	Susi::HttpClient client("http://[::1]:8080");

	auto body = client.get("/assets/wrong_test.txt");
	status = client.getStatus();

	//std::cout<<"Status: "<<status<<std::endl;
	//std::cout<<"Body: "<<body<<std::endl;	

	EXPECT_EQ(404,status);
{'fraction_non_alphanumeric': 0.19625212947189097, 'fraction_numerical': 0.013969335604770016, 'mean_word_length': 5.957345971563981, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 2, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6524716', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1042, 'n_words': 168}