def get_movie_projections(movie_id, date=None) -> tuple: """ Given a movie_id and an optional date, return the appropriate movie projections """ movie = session.query(MovieSchema).get(movie_id) if not movie: print("Invalid movie id!") return None, None elif date and not is_valid_date(date): print('Invalid date! Date should be in the format of YYYY-MM-DD!') return None, None return movie, movie.projections
def test_is_valid_date_empty_str(self): self.assertFalse(is_valid_date(""))
def test_is_valid_date_none_month(self): self.assertFalse(is_valid_date(None))
def test_is_valid_date_number(self): self.assertFalse(is_valid_date(20160231))
def test_is_valid_date_negative_month(self): self.assertFalse(is_valid_date("2016--2-31"))
def test_is_valid_date_invalid_month(self): self.assertFalse(is_valid_date("2016-13-31"))
def test_is_valid_date_invalid_day(self): self.assertFalse(is_valid_date("2016-02-31"))
def test_is_valid_date_no_padding_zero(self): """Should be valid""" self.assertTrue(is_valid_date("2016-2-1"))
def test_is_valid_date_valid_date(self): self.assertTrue(is_valid_date("2014-10-31"))