2014-08-05 21:52:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
#undef NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#define DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <Python.h>
|
|
|
|
|
|
|
|
|
|
#include "python_testers.h"
|
|
|
|
|
|
|
|
|
|
#include "rulesets/Python_API.h"
|
|
|
|
|
#include "rulesets/Py_Filter.h"
|
|
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
init_python_api("");
|
|
|
|
|
|
2014-08-14 17:09:27 -04:00
|
|
|
run_python_string("import entity_filter");
|
2014-08-05 21:52:03 -04:00
|
|
|
|
|
|
|
|
//Try creating a filter with a valid query
|
2014-08-14 17:09:27 -04:00
|
|
|
run_python_string("test_filter=entity_filter.get_filter('entity.burn_speed=0.3')");
|
2014-08-05 21:52:03 -04:00
|
|
|
|
|
|
|
|
//Try creating an invalid filter
|
2014-08-14 17:09:27 -04:00
|
|
|
expect_python_error("entity_filter.get_filter('foobar')", PyExc_TypeError);
|
2014-08-05 21:52:03 -04:00
|
|
|
|
2014-08-11 15:46:19 -04:00
|
|
|
//test deallocator
|
|
|
|
|
run_python_string("assert(test_filter)");
|
|
|
|
|
run_python_string("del(test_filter)");
|
|
|
|
|
|
2014-08-28 17:55:09 -04:00
|
|
|
//We need PyThing components to test in-python entity matching
|
|
|
|
|
run_python_string("from server import *");
|
|
|
|
|
run_python_string("from atlas import Operation");
|
|
|
|
|
|
|
|
|
|
run_python_string("le1 = LocatedEntity('1')");
|
|
|
|
|
run_python_string("le2 = LocatedEntity('2')");
|
|
|
|
|
|
|
|
|
|
run_python_string("f = entity_filter.get_filter('entity.id=1')");
|
|
|
|
|
run_python_string("assert(f.match_entity(le1))");
|
|
|
|
|
run_python_string("assert(not f.match_entity(le2))");
|
|
|
|
|
|
2014-08-05 21:52:03 -04:00
|
|
|
shutdown_python_api();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|