def test_greeting_intro(self, user, text): g = Greeting() reply, confidence = g.listen(text, user=user) assert confidence == 1.0 assert reply is not None assert reply == "Hello, what is your name?"
def testUniqueList(self): self.clearGreetingDb() self.addGreeting("one") self.addGreeting("two") self.addGreeting("two") self.addGreeting("two") self.addGreeting("three") self.assertEqual(5, len(Greeting().all().fetch(None))) self.assertEqual(3, len(Greeting().uniqueList()))
def test_initial_intro(self, user, text): g = Greeting() reply, confidence = g.listen(text, user=user) assert confidence == 1.0 assert reply is not None assert reply == "Hello, Jake!" if user is None: user = "******" assert user in g.participants assert g.participants[user] == 'Jake'
def post(self): greeting = Greeting() cont = self.request.get('content') if cont != "": if cont.lower().find("http") >= 0: self.response.out.write("<h4>Sorry, HTTP is not allowed in the comment.</h4>Use the Back button to return to the Guest Book.") return if users.get_current_user(): greeting.author = users.get_current_user() greeting.content = cont greeting.put() self.redirect('/') else: self.response.out.write("<h4>Please enter a comment.</h4>Use the Back button to return to the Guest Book.")
def getGreetings(self): # Fetch the greetings from GAE guestbook entry and return greetings and guestbook name greetings_query = Greeting.query( ancestor=guestbook_key(self.guestbook_name)).order(-Greeting.date) greetings = greetings_query.fetch(10) return greetings, self.guestbook_name
def test_Greeter_GivenFourNames_ShouldGreetWithAllNames(self): # Arrange names = ["Tom", "Bob", "Nkule", "Lungelo"] # Act result = Greeting.Greeter(names) # Assert expected = "Hello, Tom, Bob, Nkule and Lungelo" self.assertEqual(result, expected)
def test_Greeter_GivenTwoNames_ShouldGreetWithBothNames(self): # Arrange name = ["Tom", "Bob"] # Act result = Greeting.Greeter(name) # Assert expected = "Hello, Tom and Bob" self.assertEqual(result, expected)
def test_Greeter_GivenAnyNumberOfNames_ShouldGreetWithAllNames(self): # Arrange names = ["Rick", "Morty", "Summer", "Beth", "Jerry", "Chris"] # Act result = Greeting.Greeter(names) # Assert expected = "Hello, Rick, Morty, Summer, Beth, Jerry and Chris" self.assertEqual(result, expected)
def test_Greeter_GivenNull_ShouldReturnHelloFriend(self): # Arrange name = None # Act result = Greeting.Greeter(name) # Assert expected = "Hello, friend" self.assertEqual(result, expected)
def test_Greeter_GivenMixOfNormalAndShoutedNames_ShouldGreetWithAllNamesAndShoutAtTheEnd( self): # Arrange names = ["Rick", "Morty", "Summer", "BETH", "Jerry", "Chris"] # Act result = Greeting.Greeter(names) # Assert expected = "Hello, Rick, Morty, Summer, Jerry and Chris. AND BETH" self.assertEqual(result, expected)
def test_Greeter_GivenSingleName_ShouldGreetSingleName(self): singleNames = ["Bob", "Mary", "Tom"] for eachName in singleNames: # Arrange name = eachName # Act result = Greeting.Greeter(name) # Assert expected = "Hello, " + name self.assertEqual(result, expected)
def test_Greeter_GivenShoutedNames_ShouldReturnGreetingInAllCaps(self): shoutedNames = ["TOM", "BOB", "MARY", "NKULE"] for eachName in shoutedNames: # Arrange name = eachName # Act result = Greeting.Greeter(name) # Assert expected = "HELLO, " + name self.assertEqual(result, expected)
def addGreeting(self, gid, date, content): # to do greeting = Greeting(parent=guestbook_key(self.guestbook_name)) greeting.gid = gid greeting.content = content #greeting.date=date greeting.put() return greeting.date
def get(self): greetings = Greeting().uniqueList() if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Login' template_values = { 'greetings': greetings, 'url': url, 'url_linktext': url_linktext, } path = os.path.join(os.path.dirname(__file__), 'index.html') self.response.out.write(template.render(path, template_values))
def post(self): greeting = Greeting() cont = self.request.get('content') if cont != "": if cont.lower().find("http") >= 0: self.response.out.write( "<h4>Sorry, HTTP is not allowed in the comment.</h4>Use the Back button to return to the Guest Book." ) return if users.get_current_user(): greeting.author = users.get_current_user() greeting.content = cont greeting.put() self.redirect('/') else: self.response.out.write( "<h4>Please enter a comment.</h4>Use the Back button to return to the Guest Book." )
def test_hello(self): greet = Greeting() self.assertEqual("Hello Yoda", greet.hello("Yoda"))
def testInsertEntity(self): Greeting().put() self.assertEqual(1, len(Greeting.all().fetch(2)))
def update_greeting(self): print('--------greeting starting--------') g = Greeting(self.ip, self.port, self.db_name) g.update() print('--------greeting ok--------')
from greeting import Greeting from welcome import Welcome welcome_1 = Welcome("Hello!", "James") welcome_2 = Welcome("Hola!", "Sarah") welcome_3 = Welcome("Bonjour!") greeting_1 = Greeting("Hiya") greeting_2 = Greeting("Wassap") greeting_3 = Greeting("Greetings!") messages = [ welcome_1, welcome_2, welcome_3, greeting_1, greeting_2, greeting_3 ] for message in messages: print(message.display()) print()
from greeting import Greeting # Retrieve the user's name name = raw_input('What is your name? ') Greeting = Greeting(name) Greeting.sayHello()
def clearGreetingDb(self): for g in Greeting.all(): Greeting.delete(g)
def hello(name): greeting = Greeting('Hello', escape(name)) return json.dumps(greeting.__dict__)
def main(): print(Banner('hello app').content) print(Greeting(NamePrompt().input()).greet())
def addGreeting(self, content): greeting = Greeting() greeting.content = content greeting.put()