def test_write_permacache_sr(self): stdin = StringIO("\t".join([ "sr/link/top/hour/1", "1", "100.0", "t3_1", ])) stdout = StringIO() MrTop.write_permacache(fd=stdin, out=stdout) self.queries._get_links.assert_called_once_with(1, "top", "hour")
def test_write_permacache_domain(self): stdin = StringIO("\t".join([ "domain/link/top/hour/foo.com", "1", "100.0", "t3_1", ])) stdout = StringIO() MrTop.write_permacache(fd=stdin, out=stdout) self.queries.get_domain_links.assert_called_once_with( "foo.com", "top", "hour")
def test_write_permacache_domain(self): stdin = StringIO("\t".join([ "domain/link/top/hour/foo.com", "1", "100.0", "t3_1", ])) stdout = StringIO() MrTop.write_permacache(fd=stdin, out=stdout) self.queries.get_domain_links.assert_called_once_with( "foo.com", "top", "hour" )
def test_write_no_limiting(self): stdin = StringIO("\n".join([ "\t".join([ "sr/link/top/hour/1", "1", "100.0", "t3_1", ]), "\t".join([ "sr/link/top/hour/1", "1", "100.0", "t3_2", ]), ])) stdout = StringIO() query = self.queries._get_links.return_value = MagicMock() MrTop.write_permacache(fd=stdin, out=stdout) self.assertEqual(len(query._replace.call_args[0][0]), 2)
def test_write_permacache_unknown(self): stdin = StringIO("\t".join([ "something/link/top/hour/1", "1", "100.0", "t3_1", ])) stdout = StringIO() self.assertRaises( AssertionError, lambda: MrTop.write_permacache(fd=stdin, out=stdout), )