def test_eq(self): flags1 = sql_builder.Flags(flags_present=0x3, flags_absent=0x30) self.assertEqual( flags1, sql_builder.Flags(flags_present=0x3, flags_absent=0x30)) self.assertNotEqual( flags1, sql_builder.Flags(flags_present=0x30, flags_absent=0x3)) self.assertNotEqual(flags1, 'abcde') self.assertNotEqual('abcde', flags1)
def test_flags(self): flags = sql_builder.Flags(flags_present=0x1, flags_absent=0x2) sql, bind_vars = flags.build_update_value_sql('flags') self.assertEqual( sql, '(flags | %(update_flags_add)s) & ~%(update_flags_remove)s') self.assertEqual( bind_vars, dict(update_flags_add=0x1, update_flags_remove=0x2))
def test_flags(self): self._check_build_where_sql( sql_builder.Flags(flags_present=0x1, flags_absent=0x2), 'col_a & %(col_a_mask_3)s = %(col_a_value_4)s', dict(col_a_mask_3=3, col_a_value_4=1))
def test_or(self): flags = sql_builder.Flags(flags_present=0x3, flags_absent=0x30) flags |= sql_builder.Flags(flags_present=0x5, flags_absent=0x50) self.assertEqual(flags.mask, 0x77) self.assertEqual(flags.value, 0x7)
def test_repr(self): self.assertEqual( repr(sql_builder.Flags(flags_present=0x1, flags_absent=0x2)), 'Flags(flags_present=0x1, flags_absent=0x2)')