def test_validating_missing_metadata(self): metadata = {} errors, warnings = validate_workshop_metadata(metadata) assert len(errors) == 9 # There are nine required fields assert len(warnings) == 3 # There are three optional fields assert all( [issue.startswith('Missing') for issue in (errors + warnings)])
def test_validating_empty_metadata(self): metadata = { "slug": "", "language": "", "startdate": "", "enddate": "", "country": "", "venue": "", "address": "", "latlng": "", "instructor": "", "helper": "", "contact": "", "eventbrite": "", } expected_errors = [ "slug", "startdate", "country", "latlng", "instructor", "helper", "contact", ] errors, warnings = validate_workshop_metadata(metadata) assert not warnings for error, key in zip(errors, expected_errors): self.assertIn(key, error)
def test_validating_correct_metadata(self): metadata = { 'slug': '2015-07-13-test', 'language': 'us', 'startdate': '2015-07-13', 'enddate': '2015-07-14', 'country': 'us', 'venue': 'Euphoric State University', 'address': 'Highway to Heaven 42, Academipolis', 'latlng': '36.998977, -109.045173', 'eventbrite': '10000000', 'instructor': 'Hermione Granger, Ron Weasley', 'helper': 'Peter Parker, Tony Stark, Natasha Romanova', 'contact': '[email protected], [email protected]', } errors, warnings = validate_workshop_metadata(metadata) assert not warnings assert not errors
def test_validating_correct_metadata(self): metadata = { "slug": "2015-07-13-test", "language": "us", "startdate": "2015-07-13", "enddate": "2015-07-14", "country": "us", "venue": "Euphoric State University", "address": "Highway to Heaven 42, Academipolis", "latlng": "36.998977, -109.045173", "eventbrite": "10000000", "instructor": "Hermione Granger, Ron Weasley", "helper": "Peter Parker, Tony Stark, Natasha Romanova", "contact": "[email protected], [email protected]", } errors, warnings = validate_workshop_metadata(metadata) assert not warnings assert not errors
def test_validating_invalid_metadata(self): metadata = { 'slug': 'WRONG FORMAT', 'language': 'ENGLISH', 'startdate': '07/13/2015', 'enddate': '07/14/2015', 'country': 'USA', 'venue': 'Euphoric State University', 'address': 'Highway to Heaven 42, Academipolis', 'latlng': '3699e-4, -1.09e2', 'instructor': 'Hermione Granger, Ron Weasley', 'helper': 'Peter Parker, Tony Stark, Natasha Romanova', 'contact': '[email protected], [email protected]', 'eventbrite': 'bigmoney', } errors, warnings = validate_workshop_metadata(metadata) assert len(errors) == 7 assert not warnings assert all([error.startswith('Invalid value') for error in errors])
def test_validating_invalid_metadata(self): metadata = { "slug": "WRONG FORMAT", "language": "ENGLISH", "startdate": "07/13/2015", "enddate": "07/14/2015", "country": "USA", "venue": "Euphoric State University", "address": "Highway to Heaven 42, Academipolis", "latlng": "3699e-4, -1.09e2", "instructor": "Hermione Granger, Ron Weasley", "helper": "Peter Parker, Tony Stark, Natasha Romanova", "contact": "[email protected], [email protected]", "eventbrite": "bigmoney", } errors, warnings = validate_workshop_metadata(metadata) assert len(errors) == 7 assert not warnings assert all([error.startswith("Invalid value") for error in errors])
def test_validating_default_metadata(self): metadata = { 'slug': 'FIXME', 'language': 'FIXME', 'startdate': 'FIXME', 'enddate': 'FIXME', 'country': 'FIXME', 'venue': 'FIXME', 'address': 'FIXME', 'latlng': 'FIXME', 'eventbrite': 'FIXME', 'instructor': 'FIXME', 'helper': 'FIXME', 'contact': 'FIXME', } errors, warnings = validate_workshop_metadata(metadata) assert len(errors) == 12 assert not warnings assert all([ error.startswith('Placeholder value "FIXME"') for error in errors ])
def test_validating_default_metadata(self): metadata = { "slug": "FIXME", "language": "FIXME", "startdate": "FIXME", "enddate": "FIXME", "country": "FIXME", "venue": "FIXME", "address": "FIXME", "latlng": "FIXME", "eventbrite": "FIXME", "instructor": "FIXME", "helper": "FIXME", "contact": "FIXME", } errors, warnings = validate_workshop_metadata(metadata) assert len(errors) == 12 assert not warnings assert all([ error.startswith('Placeholder value "FIXME"') for error in errors ])
def test_validating_empty_metadata(self): metadata = { 'slug': '', 'language': '', 'startdate': '', 'enddate': '', 'country': '', 'venue': '', 'address': '', 'latlng': '', 'instructor': '', 'helper': '', 'contact': '', 'eventbrite': '', } expected_errors = [ 'slug', 'startdate', 'country', 'latlng', 'instructor', 'helper', 'contact' ] errors, warnings = validate_workshop_metadata(metadata) assert not warnings for error, key in zip(errors, expected_errors): self.assertIn(key, error)