예제 #1
0
    def tearDown(self):
        """
        Remove initial records form the 'files' table.
        Return initial blacklist content.
        """
        files.delete().where(files.c.hash.in_(self.files_id)).execute()

        with open(self.app.config['BLACKLIST_FILE'], 'w') as fp:
            fp.write(self.initial_blacklist)
예제 #2
0
    def tearDown(self):
        """
        Switch off some test configs.
        Remove initial files from Upload Dir.
        Remove initial records form the 'files' table.
        """
        self.patcher.stop()

        os.unlink(self.file_saving_path)
        files.delete().where(files.c.hash.in_(self.files_id)).execute()
예제 #3
0
    def test_success_get_info_with_no_files(self):
        """
        Successful getting files info with noo files.
        """
        files.delete().execute()

        with self.app.test_client() as c:
            response = c.get(path=self.url)

        self.assertEqual(200, response.status_code,
                         "'OK' status code is expected.")
        self.assertEqual('application/json', response.content_type,
                         "Has to be a JSON-response.")

        self.assertListEqual([], json.loads(response.data.decode()))
예제 #4
0
    def tearDown(self):
        """
        Switch off some test configs.
        Remove initial files from Upload Dir.
        Remove initial records form the 'files' table.
        Return initial blacklist content.
        """
        self.patcher.stop()

        try:
            pass
            os.unlink(self.file_saving_path)
        except OSError:
            pass

        files.delete().where(files.c.hash.in_(self.files_id)).execute()

        with open(self.app.config['BLACKLIST_FILE'], 'w') as fp:
            fp.write(self.initial_blacklist)
예제 #5
0
    def tearDown(self):
        """
        Switch off some test configs.
        Remove new records form the 'files' table.
        Remove new files from Upload Dir.
        Return initial blacklist content.
        """
        self.patcher.stop()

        files.delete().where(
            files.c.hash not in (_[0] for _ in self.files)
        ).execute()

        added_files = set(
            os.listdir(self.app.config['UPLOAD_FOLDER'])
        ) - self.stored_files

        for filename in added_files:
            os.unlink(os.path.join(self.app.config['UPLOAD_FOLDER'], filename))

        with open(self.app.config['BLACKLIST_FILE'], 'w') as fp:
            fp.write(self.initial_blacklist)