def test_import_warnings(self, api): repos = fake_repos('r1', 'r2') api.get_repos.side_effect = lambda names, **kw: (find_repos_from_data( repos, names)) api.validate_content = lambda *a, **kw: { 'errors': [], 'warnings': [{ 'type': 'fake_warning' }] } schedule_import_content(repos, ['en', 'fr'], 'us3r', '*****@*****.**', 'h0st', delay=False) self.assertEqual(len(mail.outbox), 1) [email] = mail.outbox self.assertEqual(email.subject, 'Content Import') self.assertEqual(email.from_email, '*****@*****.**') self.assertEqual(email.to, ['*****@*****.**']) self.assertTrue('us3r' in email.body) self.assertTrue('h0st' in email.body) self.assertTrue('is complete' in email.body) self.assertTrue('Warnings' in email.body) self.assertTrue('fake_warning' in email.body) self.assertFalse('Errors' in email.body)
def test_import_successful(self, api): imports = [] repos = fake_repos('r1', 'r2') api.get_repos.side_effect = lambda names, **kw: (find_repos_from_data( repos, names)) api.validate_content = lambda repos, *a: { repos: { 'errors': [], 'warnings': [] } }[repos] api.import_content = lambda repos, locales: (imports.append( (repos, locales))) schedule_import_content(repos, ['en', 'fr'], 'us3r', '*****@*****.**', 'h0st', delay=False) self.assertEqual(len(mail.outbox), 1) [email] = mail.outbox self.assertEqual(email.subject, 'Content Import') self.assertEqual(email.from_email, '*****@*****.**') self.assertEqual(email.to, ['*****@*****.**']) self.assertTrue('us3r' in email.body) self.assertTrue('h0st' in email.body) self.assertTrue('is complete' in email.body) self.assertFalse('Warnings' in email.body) self.assertFalse('Errors' in email.body) self.assertEqual(imports, [(repos, ['en', 'fr'])])