def test_id2vec_url(self): def route(url): self.assertEqual("https://xxx", url) with open(self._get_path(paths.ID2VEC), "rb") as fin: return fin.read() gcs_backend.requests = FakeRequests(route) with captured_output() as (out, _, _): dump_model(self._get_args(input="https://xxx")) self.assertEqual(out.getvalue(), self.ID2VEC_DUMP)
def test_id2vec_id(self): def route(url): if gcs_backend.INDEX_FILE in url: return '{"models": {"id2vec": {' \ '"92609e70-f79c-46b5-8419-55726e873cfc": ' \ '{"url": "https://xxx"}}}}'.encode() self.assertEqual("https://xxx", url) with open(self._get_path(paths.ID2VEC), "rb") as fin: return fin.read() gcs_backend.requests = FakeRequests(route) with captured_output() as (out, err, _): dump_model( self._get_args(input="92609e70-f79c-46b5-8419-55726e873cfc")) self.assertEqual(out.getvalue(), self.ID2VEC_DUMP) self.assertFalse(err.getvalue())
def test_coocc(self): with captured_output() as (out, _, _): dump_model(self._get_args(input=self._get_path(paths.COOCC))) self.assertEqual(out.getvalue(), self.COOCC_DUMP)
def test_nbow(self): with captured_output() as (out, _, _): dump_model(self._get_args(input=self._get_path(paths.NBOW))) self.assertEqual(out.getvalue(), self.NBOW_DUMP)
def test_docfreq(self): with captured_output() as (out, _, _): dump_model(self._get_args(input=self._get_path(paths.DOCFREQ))) self.assertEqual(out.getvalue(), self.DOCFREQ_DUMP)
def test_id2vec(self): with captured_output() as (out, _, _): dump_model(self._get_args(input=self._get_path(paths.ID2VEC))) self.assertEqual(out.getvalue(), self.ID2VEC_DUMP)