class UserManagerTests(TestCase): def setUp(self): self.um = UserManager('test-data/config/sqlite3_config.json') super(UserManagerTests, self).setUp() def test_user_exists(self): self.assertIsNotNone(self.um.get(100)) def test_user_not_exists(self): with self.assertRaises(UserManagerException): self.um.get(101) def test_no_filter(self): res = self.um.all() self.assertEqual(len(res), 100) def test_single_filter(self): res = self.um.filter('age=37') self.assertEqual(len(res), 2) def test_multiple_filter(self): res = self.um.filter(['gender="Male"', 'age<35']) self.assertEqual(len(res), 18) def test_custom_filter(self): res = self.um.filter('age=37 OR gender="Male"') self.assertEqual(len(res), 51) def test_aggregate_filter(self): res = self.um.filter(['age=37', 'run_duration_avg<13']) self.assertEqual(len(res), 1) def test_non_exposed_filter(self): um = UserManager('test-data/config/sqlite3_config_hide-age.json') with self.assertRaises(PropertyNotFoundException): um.filter('age=37')
def get_user_manager(self, token=None): if not token: token = uuid.uuid4() return UserManager(from_str=self.to_json(), token=token)
def test_non_exposed_filter(self): um = UserManager('test-data/config/sqlite3_config_hide-age.json') with self.assertRaises(PropertyNotFoundException): um.filter('age=37')
def setUp(self): self.um = UserManager('test-data/config/sqlite3_config.json') super(UserManagerTests, self).setUp()