def test_instantiating_corpus_from_url_fails(self, mocked_get): mocked_get.return_value.status_code = 403 mocked_get.return_value.json.return_value = self.example_json url = self.example_json['url'] with self.assertRaises(RuntimeError): corpus = Corpus.from_url(url, ('wrong_user', 'my_precious'))
def test_instantiate_corpus_from_url(self, mocked_get): mocked_get.return_value.status_code = 200 mocked_get.return_value.json.return_value = self.example_json url = self.example_json['url'] corpus = Corpus.from_url(url, self.auth) mocked_get.assert_called_with(url) self.assertIsInstance(corpus, Corpus) for k, v in self.example_json.items(): self.assertEqual(getattr(corpus, k), v) self.assertEqual(corpus.session.auth, self.auth)