示例#1
0
    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?"
示例#2
0
 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()))
示例#3
0
    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'
示例#4
0
  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.")
示例#5
0
    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)
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
 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)
示例#13
0
 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
示例#14
0
    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))
示例#15
0
    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."
            )
示例#16
0
 def test_hello(self):
   greet = Greeting()
   self.assertEqual("Hello Yoda", greet.hello("Yoda"))
示例#17
0
 def testInsertEntity(self):
     Greeting().put()
     self.assertEqual(1, len(Greeting.all().fetch(2)))
示例#18
0
 def update_greeting(self):
     print('--------greeting starting--------')
     g = Greeting(self.ip, self.port, self.db_name)
     g.update()
     print('--------greeting ok--------')
示例#19
0
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()
示例#20
0
from greeting import Greeting

# Retrieve the user's name
name = raw_input('What is your name? ')

Greeting = Greeting(name)

Greeting.sayHello()
示例#21
0
 def clearGreetingDb(self):
     for g in Greeting.all():
         Greeting.delete(g)
示例#22
0
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())
示例#24
0
 def addGreeting(self, content):
     greeting = Greeting()
     greeting.content = content
     greeting.put()