Beispiel #1
0
    def test_book_info(self):
        tests = []
        for name in self.test_data:
            tests.append(name)
        for test in tests:
            # print("=========" + test + "========")
            test_input = self.test_data[test]
            is_author = test_input["is_author"]
            result = main_handler.lambda_handler(test_input, None)

            sess = requests.Session()
            sess.headers.update(self.headers)

            right_result = sess.request(url=test_input['url'],
                                        method='GET').json()
            sess.close()

            subject = test_input.get('subject', 'default subject')
            author = test_input.get('author')
            if is_author:
                assert (result == book_info.parse_author(
                    right_result, {'author': author}))
            else:
                assert (result == book_info.parse_subject(
                    right_result, subject, {'author': author}))
Beispiel #2
0
 def test_basic_help(self):
     event = ['basic', 'help_roberts_coffee', 'help_weather',
              'help_location','need_help_location', 'help_books',
              'help_author', 'help_random']
     for i in event:
         test_str = self.test_data[i]
         result = main_handler.lambda_handler(test_str, None)
         print("result", result)
         assert (result is not None)
Beispiel #3
0
 def test_categories(self):
     print("----------CATEGORIES----------")
     for category in self.json_data:
         print("name", category)
         event = self.test_data[category]
         # print("data", event)
         # print(event['name'])
         result = main_handler.lambda_handler(event, None)
         print("result", result['dialogAction']['message']['content'])
         assert (result['dialogAction']['message']['content'] is not None)
     print("number of categories tested: " + str(len(self.json_data)))
Beispiel #4
0
 def test_categories(self):
     print("----------CATEGORIES----------")
     for category in self.json_data:
         # print("name", category)
         event = self.test_data[category]
         # print("data", event)
         # print(event['name'])
         result = main_handler.lambda_handler(event, None)
         should = robertscoffee.drinks(
             event['currentIntent']['slots']['category'])
         print("result", result['dialogAction']['message']['content'])
         print("should", should['dialogAction']['message']['content'])
         assert (result == should)
         assert (result['dialogAction']['message']['content'] is not None)
     print("number of categories tested: " + str(len(self.json_data)))
Beispiel #5
0
    def test_drinks(self):
        print("----------DRINKS----------")
        final_map = {}
        for i in self.json_data.values():
            final_map.update(i)

        for name in final_map:
            print("name", name)
            event = self.test_data[name]
            # print("data", event)
            # print(event['name'])
            result = main_handler.lambda_handler(event, None)
            print("result", result['dialogAction']['message']['content'])
            assert (result['dialogAction']['message']['content'] is not None)
        print("number of drinks tested: " + str(len(final_map)))
Beispiel #6
0
 def test_intro(self):
     result = main_handler.lambda_handler(self.test_data["category"], None)
     print("result", result['dialogAction']['message']['content'])
     assert (result == robertscoffee.intro())
     assert (result['dialogAction']['message']['content'] is not None)
Beispiel #7
0
 def test_weather(self):
     json_data = json.load(open("./tests/weather_test.json"))
     result = main_handler.lambda_handler(json_data, None)
     assert (result is not None)