Пример #1
0
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')
Пример #2
0
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')
Пример #3
0
    def get_user_manager(self, token=None):
        if not token:
            token = uuid.uuid4()

        return UserManager(from_str=self.to_json(), token=token)
Пример #4
0
 def test_non_exposed_filter(self):
     um = UserManager('test-data/config/sqlite3_config_hide-age.json')
     with self.assertRaises(PropertyNotFoundException):
         um.filter('age=37')
Пример #5
0
 def setUp(self):
     self.um = UserManager('test-data/config/sqlite3_config.json')
     super(UserManagerTests, self).setUp()
Пример #6
0
 def test_non_exposed_filter(self):
     um = UserManager('test-data/config/sqlite3_config_hide-age.json')
     with self.assertRaises(PropertyNotFoundException):
         um.filter('age=37')
Пример #7
0
 def setUp(self):
     self.um = UserManager('test-data/config/sqlite3_config.json')
     super(UserManagerTests, self).setUp()