Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_set_4(self):
s = edgedb.Set(([],))
s[0].append(s)
self.assertEqual(repr(s), "Set{[Set{...}]}")
def test_object_links_1(self):
O2 = private.create_object_factory(
id='property',
lb='link-property',
c='property'
)
O1 = private.create_object_factory(
id='property',
o2s='link'
)
o2_1 = O2(1, 'linkprop o2 1', 3)
o2_2 = O2(4, 'linkprop o2 2', 6)
o1 = O1(2, edgedb.Set((o2_1, o2_2)))
linkset = o1['o2s']
self.assertEqual(len(linkset), 2)
self.assertEqual(linkset, o1['o2s'])
self.assertEqual(hash(linkset), hash(o1['o2s']))
self.assertEqual(
repr(linkset),
"LinkSet(name='o2s', source_id=2, target_ids={1, 4})")
link1 = linkset[0]
self.assertIs(link1.source, o1)
self.assertIs(link1.target, o2_1)
self.assertEqual(
repr(link1),
"Link(name='o2s', source_id=2, target_id=1)")
self.assertEqual(set(dir(link1)), {'target', 'source', 'lb'})
def test_object_links_2(self):
User = private.create_object_factory(
id='property',
friends='link',
enemies='link',
)
u1 = User(1, edgedb.Set([]), edgedb.Set([]))
u2 = User(2, edgedb.Set([]), edgedb.Set([]))
u3 = User(3, edgedb.Set([]), edgedb.Set([]))
u4 = User(4, edgedb.Set([u1, u2]), edgedb.Set([u1, u2]))
u5 = User(5, edgedb.Set([u1, u3]), edgedb.Set([u1, u2]))
self.assertNotEqual(u4['friends'], u4['enemies'])
self.assertNotEqual(u4['enemies'], u5['enemies'])
self.assertEqual(set(dir(u1)), {'id', 'friends', 'enemies'})
def test_sync_args_01(self):
self.assertEqual(
self.con.query(
'select (>$foo)[0] ++ (>$bar)[0];',
foo=['aaa'], bar=['bbb']),
edgedb.Set(('aaabbb',)))
DROP PROPERTY prop1;
}};
ALTER TYPE test::{typename} {{
CREATE REQUIRED PROPERTY prop1 -> std::int64;
}};
INSERT test::{typename} {{
prop1 := 123
}};
''')
for _ in range(5):
self.assertEqual(
await self.con.fetchall(query),
edgedb.Set([123]))
finally:
await self.con.execute('ROLLBACK')
def test_set_5(self):
self.assertEqual(
edgedb.Set([1, 2, 3]),
edgedb.Set([3, 2, 1]))
self.assertEqual(
edgedb.Set([]),
edgedb.Set([]))
self.assertEqual(
edgedb.Set([1]),
edgedb.Set([1]))
self.assertNotEqual(
edgedb.Set([1]),
edgedb.Set([]))
self.assertNotEqual(
edgedb.Set([1]),
edgedb.Set([2]))
def test_sync_basic_datatypes_02(self):
self.assertEqual(
self.con.query(
r'''select [b"\x00a", b"b", b'', b'\na']'''),
edgedb.Set([[b"\x00a", b"b", b'', b'\na']]))
self.assertEqual(
self.con.query(
r'select $0', b'he\x00llo'),
edgedb.Set([b'he\x00llo']))
def test_set_3(self):
s = edgedb.Set(())
self.assertEqual(len(s), 0)
self.assertEqual(hash(s), hash(edgedb.Set(())))
self.assertNotEqual(hash(s), hash(()))
async def test_async_args_02(self):
self.assertEqual(
await self.con.query(
'select (>$0)[0] ++ (>$1)[0];',
['aaa'], ['bbb']),
edgedb.Set(('aaabbb',)))
def test_set_3(self):
s = edgedb.Set(())
self.assertEqual(len(s), 0)
self.assertEqual(hash(s), hash(edgedb.Set(())))
self.assertNotEqual(hash(s), hash(()))