def test_on_companies_list_with_elements(self, urlopen):
     prepare_url_open(
         urlopen,
         {COMPANIES_URL: [{"permalink": "foo"}, {"permalink": "bar"}], FOO_URL: ["some_foo"], BAR_URL: ["some_bar"]},
     )
     self.assertEqual(self._call_cmd("-q", self.tmpd), 0)
     try:
         urlopen.assert_called_with(BAR_URL)
     except AssertionError:  # pragma: no cover
         urlopen.assert_called_with(FOO_URL)
     listing = os.listdir(self.tmpd)
     listing.sort()
     self.assertEqual(listing, ["bar.json", "foo.json"])
     with open(os.path.join(self.tmpd, "bar.json")) as fp:
         self.assertEqual(json.loads(fp.read()), ["some_bar"])
     with open(os.path.join(self.tmpd, "foo.json")) as fp:
         self.assertEqual(json.loads(fp.read()), ["some_foo"])
 def test_on_empty_companies_list(self, urlopen):
     url_return = {COMPANIES_URL: []}
     prepare_url_open(urlopen, url_return)
     self.assertEqual(self._call_cmd(self.tmpd), 0)
     urlopen.assert_called_once_with(COMPANIES_URL)
     self.assertEqual(os.listdir(self.tmpd), [])
示例#3
0
 def test_update(self, urlopen):
     prepare_url_open(urlopen, {COMPANIES_URL: [{"permalink": "foo"}]})
     cl = self._make_one(None)
     cl.update()
     urlopen.assert_called_once_with(COMPANIES_URL)
示例#4
0
 def test_update(self, urlopen):
     prepare_url_open(urlopen, {FOO_URL: {"foo": "bar"}})
     company = self._make_update()
     self.assertEqual(company.data, {"foo": "bar"})
     urlopen.assert_called_once_with(FOO_URL)