def test_retreive_or_make(self): s_key = speaker.make_and_store_new_speaker("*****@*****.**") self.assertTrue(speaker.speaker_exists("*****@*****.**")) s = s_key.get() s.name = "Ron Weasley" s.put() self.assertTrue(speaker.speaker_exists("*****@*****.**")) ron = speaker.retrieve_or_make("*****@*****.**") self.assertEquals("Ron Weasley", ron.name) self.assertFalse(speaker.speaker_exists("*****@*****.**")) harry = speaker.retrieve_or_make("*****@*****.**") self.assertTrue(speaker.speaker_exists("*****@*****.**")) self.assertEquals("", harry.name)
def get(self): crrt_conf = self.determine_conference() if crrt_conf == None: self.welcome_sorry() return if not(crrt_conf.are_submissions_open() or submission_overide(self)): sorrypage.redirect_sorry(self, "ConfNotOpen") return self.set_crrt_conference_key(crrt_conf.key) user = self.get_crrt_user() spkr = speaker.retrieve_or_make(user.email()) spkr.name = user.name() spkr.put() template_values = { "crrt_conf": crrt_conf, 'new_speaker': True, 'speaker': spkr, "emaillocked": "readonly", 'speakerKey': spkr.key.urlsafe(), 'readonly': "", } self.write_page('submission_lib/flowpage1.html', template_values)
def test_find_blank_bios(self): harry = speaker.retrieve_or_make("*****@*****.**") harry.bio = "Harry is a really nice guy" ron = speaker.retrieve_or_make("*****@*****.**") hagrid = speaker.retrieve_or_make("*****@*****.**") hagrid.bio = "Hagrid is big" hammy = speaker.retrieve_or_make("*****@*****.**") spk_list = speaker_checks.filter_for_blank_bios( speaker.Speaker.query().fetch()) self.assertEquals(2, len(spk_list)) self.assertListEqual([ron, hammy], spk_list)
def submission_from_login(self): self.crrt_conf = ndb.Key(urlsafe=self.session["singlesubmit"]).get() if self.is_conference_closed(self.crrt_conf): return False user = self.get_crrt_user() self.submitter = speaker.retrieve_or_make(user.email()) self.submitter.name = user.name() self.submitter.put() return True
def process_speaker(self, messages): # Now users must login user account will exist in the system # Therefore can remove checks about eixsting or new user # Existing details will be shown on get # So already read and store them here email = self.request.get("email") spk = speaker.retrieve_or_make(email) speaker_fragment.read_speaker_dir(self, spk) speaker_fragment.read_and_store_fields(self, spk) return spk
def test_is_bio_blank(self): spk = speaker.retrieve_or_make("*****@*****.**") self.assertTrue(speaker_checks.is_bio_blank(spk)) spk.bio = "Harry is a really nice guy" self.assertFalse(speaker_checks.is_bio_blank(spk))