def test__get_session_variables_returns_saved_values(self): planet_story = PlanetStory({ 'current_question': 'star_brightness', 'star': { 'brightness': 'red', 'size': 'giant', 'age': 'old' }, 'planet': { 'size': 'huge', 'distance': 'far', 'age': 'old' } }) session_variables = planet_story.get_session_variables() question = session_variables['current_question'] sun = session_variables['star'] planet = session_variables['planet'] self.assertEqual(question, Question.Star.BRIGHTNESS, 'Next question should be star brightness') self.assertEqual(sun, { 'brightness': 'red', 'size': 'giant', 'age': 'old' }, 'Should return valid sun as dictionary') self.assertEqual(planet, { 'size': 'huge', 'distance': 'far', 'age': 'old' }, 'Should return valid planet as dictionary')
def test__set_planet_distance_sets_correctly(self): planet_story = PlanetStory(None) planet_story.set_planet_distance('test') self.assertEqual(planet_story.planet.distance, 'test', 'Should be test') self.assertEqual(planet_story.planet.distance, 'test', 'Should be test')
def process(self, handler_input): print("Request received: {}".format( handler_input.request_envelope.request)) print("Entire request envelope: {}".format( viewport.get_viewport_profile(handler_input.request_envelope))) global planet_story global device device = Device( viewport.get_viewport_profile(handler_input.request_envelope)) session_attributes = handler_input.attributes_manager.session_attributes planet_story = PlanetStory(session_attributes)
def test__get_session_variables_returns_valid_defaults(self): planet_story = PlanetStory(None) session_variables = planet_story.get_session_variables() question = session_variables['current_question'] sun = session_variables['star'] planet = session_variables['planet'] self.assertEqual(question, Question.Star.BRIGHTNESS, 'Next question should be star brightness') self.assertEqual(sun, { 'brightness': '', 'size': '', 'age': '' }, 'Should return valid sun as dictionary') self.assertEqual(planet, { 'size': '', 'distance': '', 'age': '' }, 'Should return valid planet as dictionary')
def test__constructor_take_none(self): planet_story = PlanetStory(None) self.assertEqual(planet_story.current_question, Question.Star.BRIGHTNESS, 'Next question should be star brightness') self.assertEqual(planet_story.star.brightness, '', 'Sun should be an empty dictionary') self.assertEqual(planet_story.star.size, '', 'Sun should be an empty dictionary') self.assertEqual(planet_story.planet.distance, '', 'Sun should be an empty dictionary') self.assertEqual(planet_story.planet.size, '', 'Sun should be an empty dictionary')
def test__set_sun_brightness_sets_correctly(self): planet_story = PlanetStory(None) planet_story.set_star_brightness('test') self.assertEqual(planet_story.star.brightness, 'test', 'Should be test')
def test__set_star_size_sets_correctly(self): planet_story = PlanetStory(None) planet_story.set_star_size('test') self.assertEqual(planet_story.star.size, 'test', 'Should be test')