예제 #1
0
    def test_cli_single(self):
        instaLooter.main(
            ["post", "https://www.instagram.com/p/BFB6znLg5s1/", self.tmpdir])
        self.assertIn("1243533605591030581.jpg", os.listdir(self.tmpdir))

        instaLooter.main(["post", "BIqZ8L8AHmH", self.tmpdir])
        self.assertIn("1308972728853756295.jpg", os.listdir(self.tmpdir))
예제 #2
0
 def test_cli_nodirectory(self):
     """Issue #19 acceptance test
     """
     initial_dir = os.getcwd()
     os.chdir(self.tmpdir)
     instaLooter.main(["mysteryjets", "-n", "10", "-q"])
     self.assertEqual(len(os.listdir(self.tmpdir)), 10)
     os.chdir(initial_dir)
예제 #3
0
 def test_dump_only(self):
     instaLooter.main(
         ["post", "BIqZ8L8AHmH", self.tmpdir, '-q', '--dump-only'])
     self.assertIn("1308972728853756295.json", os.listdir(self.tmpdir))
     self.assertNotIn("1308972728853756295.jpg", os.listdir(self.tmpdir))
     with open(os.path.join(self.tmpdir, "1308972728853756295.json")) as fp:
         json_metadata = json.load(fp)
     self.assertEqual("1308972728853756295", json_metadata["id"])
     self.assertEqual("BIqZ8L8AHmH", json_metadata["code"])
예제 #4
0
 def test_cli_template(self):
     """Issue #14 CLI acceptance test
     """
     instaLooter.main([
         "mysteryjets", self.tmpdir, "-n", "10", "-q", "-T",
         "{username}.{date}.{id}"
     ])
     for f in os.listdir(self.tmpdir):
         self.assertTrue(f.startswith('mysteryjets'))
예제 #5
0
    def test_issue_14(self):
        """
        Feature request by @JFLarsen.

        Allows customizing filenames using a template following Python
        `.format()` minilanguage.
        """
        instaLooter.main(["mysteryjets", self.tmpdir, "-n", "10", "-q", "-T", "{username}.{date}.{id}"])
        for f in os.listdir(self.tmpdir):
            self.assertTrue(f.startswith('mysteryjets'))
예제 #6
0
    def test_issue_52(self):
        """
        Thanks to @cyrusclarke for reporting this bug.

        Checks that on hashtags with a lot of posts, the time parameter
        doesn't cause the program to crash without finding any media to
        download.
        """
        instaLooter.main(["hashtag", "happy", self.tmpdir, "-q", "-t", "thisweek", "-n", 20])
        self.assertEqual(len(os.listdir(self.tmpdir)), 20)
예제 #7
0
    def test_issue_19(self):
        """
        Thanks to @emijawdo for reporting this bug.

        Checks that instaLooter does not crash when not given a destination
        directory and uses the current directory.
        """
        initial_dir = os.getcwd()
        os.chdir(self.tmpdir)
        instaLooter.main(["mysteryjets", "-n", "10", "-q"])
        self.assertEqual(len(os.listdir(self.tmpdir)), 10)
        os.chdir(initial_dir)
예제 #8
0
    def test_issue_22(self):
        """
        Thanks to @kuchenmitsahne for reporting this bug.

        Checks that using ``{datetime}`` in the template does not put
        a Windows forbidden character in the filename.
        """
        FORBIDDEN = '<>:"/\|?*'
        instaLooter.main(["mysteryjets", self.tmpdir, "-n", "10", "-q", "-T", "{datetime}"])
        for f in os.listdir(self.tmpdir):
            for char in FORBIDDEN:
                self.assertNotIn(char, f)
예제 #9
0
    def test_issue_9(self):
        """
        Thanks to @kurtmaia for reporting this bug.

        Checks that adding metadata to pictures downloaded from a hashtag
        works as well.
        """
        instaLooter.main(["fluoxetine", self.tmpdir, "-n", "10", "-q", "--add-metadata"])
        for f in os.listdir(self.tmpdir):
            exif = piexif.load(os.path.join(self.tmpdir, f))
            self.assertTrue(exif['Exif']) # Date & Caption
            self.assertTrue(exif['0th'])  # Image creator
예제 #10
0
 def test_cli_plain(self):
     instaLooter.main(["mysteryjets", self.tmpdir, "--get-videos", "-q"])
     self.assertGreaterEqual(len(os.listdir(self.tmpdir)),
                             686)  # nb of post on 2016-12-21
예제 #11
0
 def test_fail_on_no_directory(self):
     self.assertTrue(
         instaLooter.main(
             ["post", "https://www.instagram.com/p/BFB6znLg5s1/", "-q"]))
     self.assertTrue(instaLooter.main(["hashtag", "anything", "-q"]))
예제 #12
0
 def test_single_post_with_tor(self):
     instaLooter.main(
         ["post", "BIqZ8L8AHmH", self.tmpdir, "-q", "--socks_port", "9090"])
     self.assertIn("1308972728853756295.jpg", os.listdir(self.tmpdir))
예제 #13
0
 def test_plain(self):
     instaLooter.main(["mysteryjets", self.tmpdir, "-q", '-n', '10'])
     self.assertEqual(len(os.listdir(self.tmpdir)), 10)