Exemple #1
0
 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")
Exemple #2
0
 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")
Exemple #3
0
 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")
Exemple #4
0
 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"
     )
Exemple #5
0
    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)
Exemple #6
0
 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),
     )
Exemple #7
0
    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)
Exemple #8
0
 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),
     )