def testSaveIfChanged(self):
        new_member = member_util.SaveMember(random_util.Member())
        new_member.username = '******'
        new_member.email = '*****@*****.**'
        member_util.SaveIfChanged(new_member)

        [member] = freesidemodels.Member.all().fetch(1)
        self.assertEquals(member.username, new_member.username)
        self.assertEquals(member.email, new_member.email)
 def AddMember(self):
   """Add a new member to the database."""
   #member_dict = dict(
   #  (p, self.request.get(p)) for p, cls in freesidemodels.Member._properties)
   member = member_util.SaveMember(
     member_util.MakeMember(
       username=self.request.get('username'),
       firstname=self.request.get('firstname'),
       lastname=self.request.get('lastname'),
       email=self.request.get('email'),
       password=self.request.get('password'),
       starving=self.request.get('starving') == 'True'))
   self.redirect('/admin')
    def testSaveIfChangedNotChanged(self):
        member = member_util.SaveMember(random_util.Member())

        # TODO(dknowles): Use mox instead
        called = False
        orig_save_member = member_util.SaveMember

        def MockSaveMember(member):
            called = True

        member_util.SaveMember = MockSaveMember

        member_util.SaveIfChanged(member)
        member_util.SaveMember = orig_save_member
        self.failIf(called)
 def DoSeed(count, member_list, active):
     for _ in xrange(0, count):
         member_list.append(
             member_util.SaveMember(random_util.Member(active=active)))
 def testSave(self):
     member = member_util.SaveMember(random_util.Member())
     self.assertEquals(member.key(), freesidemodels.Member.all()[0].key())