def test_fromSSO(self): """ Do I create a valid user object from SSO registration? """ ssoData = { 'email': '*****@*****.**', 'given_name': 'Sso', 'family_name': 'Dude', } with mockDatabase(): u = user.User.fromSSO(ssoData) x = user.User.objects(email='*****@*****.**').first() self.assertEqual(x.id, u.id) self.assertEqual(x.familyName, ssoData['family_name']) self.assertEqual(x.roles, [user.Roles.user])
def test_saveOnlyOnce(self): """ Test that we only save a recipe only once? """ u = user.User(email='*****@*****.**', roles=[user.Roles.user]) u.save() r = recipe.Recipe(name='Pasta', author='Katharine Chen', user=u, urlKey='something-unique', ingredients=['cookie', 'pasta'], instructions=['nom1', 'nom2', 'nom3']) with mockDatabase(): r.saveOnlyOnce() assert len(recipe.Recipe.objects()) == 1 # call it again to test that save is not called again r.saveOnlyOnce() assert len(recipe.Recipe.objects()) == 1