def test_can_get_prefs(self): user = UserFactory.create() key1 = KeyFactory.create() key2 = KeyFactory.create() UsersViolationsPrefs.insert_pref(self.db, user, key1, True) UsersViolationsPrefs.insert_pref(self.db, user, key2, False) data = UsersViolationsPrefs.get_prefs(self.db, user) expect(data).to_length(2) expect(data).to_be_like({key1.name: True, key2.name: False})
def test_can_get_prefs(self): user = UserFactory.create() key1 = KeyFactory.create() key2 = KeyFactory.create() UsersViolationsPrefs.insert_pref(self.db, user, key1, True) UsersViolationsPrefs.insert_pref(self.db, user, key2, False) data = UsersViolationsPrefs.get_prefs(self.db, user) expect(data).to_length(2) expect(data).to_be_like( {key1.name: True, key2.name: False} )
def test_can_insert_pref(self): user = UserFactory.create() key1 = KeyFactory.create() key2 = KeyFactory.create() UsersViolationsPrefs.insert_pref(self.db, user, key1, True) UsersViolationsPrefs.insert_pref(self.db, user, key2, False) prefs = self.db.query(UsersViolationsPrefs).all() expect(prefs).to_length(2) expect(prefs[0].key).to_equal(key1) expect(prefs[0].user).to_equal(user) expect(prefs[0].is_active).to_equal(True) expect(prefs[1].key).to_equal(key2) expect(prefs[1].user).to_equal(user) expect(prefs[1].is_active).to_equal(False)