コード例 #1
0
ファイル: test_orm.py プロジェクト: basherfarm/contracting
    def test_get_all_when_none_exist(self):
        contract = 'blah'
        name = 'scoob'

        h = Hash(contract, name, driver=driver, default_value=0)

        self.assertEqual(h.all(), [])
コード例 #2
0
ファイル: test_orm.py プロジェクト: basherfarm/contracting
    def test_get_all_after_setting(self):
        contract = 'blah'
        name = 'scoob'

        h = Hash(contract, name, driver=driver, default_value=0)

        h['1'] = 123
        h['2'] = 456
        h['3'] = 789

        l = [123, 456, 789]

        driver.commit()

        # we care about whats included, not order
        self.assertSetEqual(set(h.all()), set(l))
コード例 #3
0
ファイル: test_orm.py プロジェクト: basherfarm/contracting
    def test_all_multihash_returns_values(self):
        contract = 'blah'
        name = 'scoob'

        h = Hash(contract, name, driver=driver, default_value=0)

        h[0, '1'] = 123
        h[0, '2'] = 456
        h[0, '3'] = 789

        h[1, '1'] = 999
        h[1, '2'] = 888
        h[1, '3'] = 777

        l = [123, 456, 789]

        driver.commit()

        # we care about whats included, not order
        self.assertSetEqual(set(h.all(0)), set(l))
コード例 #4
0
ファイル: test_orm.py プロジェクト: basherfarm/contracting
    def test_multihash_multiple_dims_all_gets_items_similar_to_single_dim(
            self):
        contract = 'blah'
        name = 'scoob'

        h = Hash(contract, name, driver=driver, default_value=0)

        h[1, 0, '1'] = 123
        h[1, 0, '2'] = 456
        h[1, 0, '3'] = 789

        h[1, 1, '1'] = 999
        h[1, 1, '2'] = 888
        h[1, 1, '3'] = 777

        l = [123, 456, 789]

        driver.commit()

        # we care about whats included, not order
        self.assertSetEqual(set(h.all(1, 0)), set(l))