コード例 #1
0
 def test_new_record(self):
     t = self.temp_table()
     try:
         run_synchronous(
             t.new_record(id=10, less_than_two=False, name=f"hello"))
     finally:
         self.db.drop_table_sync(t.name)
コード例 #2
0
ファイル: test_database.py プロジェクト: jigold/hail
 def test_delete_records(self):
     t = self.temp_table()
     try:
         run_synchronous(t.delete_record({'id': 1}))
         records = run_synchronous(t.get_record({'id': 1}))
         assert len(records) == 0
     finally:
         self.db.drop_table_sync(t.name)
コード例 #3
0
ファイル: test_database.py プロジェクト: jigold/hail
 def test_new_record(self):
     t = self.temp_table()
     try:
         run_synchronous(t.new_record({'id': 10,
                                        'less_than_two': False,
                                        'name': f"hello"}))
     finally:
         self.db.drop_table_sync(t.name)
コード例 #4
0
 def test_delete_records(self):
     t = self.temp_table()
     try:
         run_synchronous(t.delete_record({'id': 1}))
         records = run_synchronous(t.get_record({'id': 1}))
         assert len(records) == 0
     finally:
         self.db.drop_table_sync(t.name)
コード例 #5
0
 def test_get_not_null_records(self):
     t = self.temp_table()
     try:
         run_synchronous(t.update_record({'id': 1}, {'name': None}))
         records = run_synchronous(t.get_record({'name': 'NOT NULL'}))
         assert len(records) == 4
         records = run_synchronous(t.get_record({'name': None}))
         assert len(records) == 1
     finally:
         self.db.drop_table_sync(t.name)
コード例 #6
0
ファイル: test_database.py プロジェクト: jigold/hail
    def test_update_record(self):
        t = self.temp_table()

        try:
            run_synchronous(t.update_record({'id': 3, 'name': '3'},
                                            {'name': 'hello'}))

            updated_record = run_synchronous(t.get_record({'id': 3}))
            assert len(updated_record) == 1
            assert updated_record[0]['name'] == 'hello'
        finally:
            self.db.drop_table_sync(t.name)
コード例 #7
0
    def test_backtick_names(self):
        schema = {
            'id': 'INT',
            '`less_than_two`': 'BOOLEAN',
            'name': 'VARCHAR(100)'
        }
        keys = ['id']

        t = self.db.create_temporary_table_sync("temp", schema, keys)

        try:
            records = run_synchronous(t.get_record({'`less_than_two`': True}))
            assert len(records) == 0
            run_synchronous(
                t.new_record(**{
                    'id': 5,
                    '`less_than_two`': False,
                    'name': "foo"
                }))
            assert run_synchronous(t.has_record({'`less_than_two`': False}))
            run_synchronous(
                t.update_record({'id': 5}, {'`less_than_two`': True}))
            run_synchronous(t.delete_record({'`less_than_two`': True}))
        finally:
            self.db.drop_table_sync(t.name)
コード例 #8
0
    def test_update_record(self):
        t = self.temp_table()

        try:
            run_synchronous(
                t.update_record({
                    'id': 3,
                    'name': '3'
                }, {'name': 'hello'}))

            updated_record = run_synchronous(t.get_record({'id': 3}))
            assert len(updated_record) == 1
            assert updated_record[0]['name'] == 'hello'
        finally:
            self.db.drop_table_sync(t.name)
コード例 #9
0
ファイル: test_database.py プロジェクト: jigold/hail
 def test_select_records(self):
     t = self.temp_table()
     try:
         records = run_synchronous(t.get_record({'id': 1}, ['less_than_two']))
         assert len(records) == 1
         assert records == [{'less_than_two': True}]
     finally:
         self.db.drop_table_sync(t.name)
コード例 #10
0
 def test_select_records(self):
     t = self.temp_table()
     try:
         records = run_synchronous(
             t.get_record({'id': 1}, ['less_than_two']))
         assert len(records) == 1
         assert records == [{'less_than_two': True}]
     finally:
         self.db.drop_table_sync(t.name)
コード例 #11
0
ファイル: test_database.py プロジェクト: jigold/hail
 def test_get_records(self):
     t = self.temp_table()
     try:
         records = run_synchronous(t.get_record({'id': [1, 2]}))
         assert len(records) == 2
         assert records == [{'id': 1, 'less_than_two': True, 'name': '1'},
                            {'id': 2, 'less_than_two': False, 'name': '2'}]
     finally:
         self.db.drop_table_sync(t.name)
コード例 #12
0
ファイル: test_database.py プロジェクト: jigold/hail
    def temp_table(self):
        schema = {'id': 'INT',
                  'less_than_two': 'BOOLEAN',
                  'name': 'VARCHAR(100)'}
        keys = ['id']

        t = self.db.create_temporary_table_sync("temp", schema, keys)

        for i in range(1, 6):
            id = run_synchronous(t.new_record({'id': i,
                                                'less_than_two': (i < 2),
                                                'name': f"{i}"}))
            assert id == 0
        return t
コード例 #13
0
ファイル: test_database.py プロジェクト: jigold/hail
    def test_backtick_names(self):
        schema = {'id': 'INT',
                  '`less_than_two`': 'BOOLEAN',
                  'name': 'VARCHAR(100)'}
        keys = ['id']

        t = self.db.create_temporary_table_sync("temp", schema, keys)

        try:
            records = run_synchronous(t.get_record({'`less_than_two`': True}))
            assert len(records) == 0
            run_synchronous(t.new_record({'id': 5, '`less_than_two`': False, 'name': "foo"}))
            assert run_synchronous(t.has_record({'`less_than_two`': False}))
            run_synchronous(t.update_record({'id': 5}, {'`less_than_two`': True}))
            run_synchronous(t.delete_record({'`less_than_two`': True}))
        finally:
            self.db.drop_table_sync(t.name)
コード例 #14
0
    def temp_table(self):
        schema = {
            'id': 'INT',
            'less_than_two': 'BOOLEAN',
            'name': 'VARCHAR(100)'
        }
        keys = ['id']

        t = self.db.create_temporary_table_sync("temp", schema, keys)

        for i in range(1, 6):
            id = run_synchronous(
                t.new_record(id=i, less_than_two=(i < 2), name=f"{i}"))
            assert id == 0
        return t
コード例 #15
0
 def test_get_records(self):
     t = self.temp_table()
     try:
         records = run_synchronous(t.get_record({'id': [1, 2]}))
         assert len(records) == 2
         assert records == [{
             'id': 1,
             'less_than_two': True,
             'name': '1'
         }, {
             'id': 2,
             'less_than_two': False,
             'name': '2'
         }]
     finally:
         self.db.drop_table_sync(t.name)
コード例 #16
0
 def test_has_record(self):
     t = self.temp_table()
     try:
         assert run_synchronous(t.has_record({'id': 4}))
     finally:
         self.db.drop_table_sync(t.name)
コード例 #17
0
ファイル: test_database.py プロジェクト: jigold/hail
 def test_has_record(self):
     t = self.temp_table()
     try:
         assert run_synchronous(t.has_record({'id': 4}))
     finally:
         self.db.drop_table_sync(t.name)