Skip to content

Commit

Permalink
Temp commit, plz rebase/ammend
Browse files Browse the repository at this point in the history
- Restructor the unit tests for zip render
- TODO: implement each tests
  • Loading branch information
cslzchen committed Apr 16, 2018
1 parent 0e41e88 commit 1aaf11c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 137 deletions.
Empty file removed tests/extensions/zip/__init__.py
Empty file.
Binary file removed tests/extensions/zip/files/empty.zip
Binary file not shown.
Binary file removed tests/extensions/zip/files/test-tree.zip
Binary file not shown.
Binary file removed tests/extensions/zip/files/test.zip
Binary file not shown.
Binary file added tests/extensions/zip/files/zip-empty.zip
Binary file not shown.
Binary file added tests/extensions/zip/files/zip-test.zip
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/extensions/zip/fixtures/file_tree.json
@@ -0,0 +1,9 @@
{
"file_tree":[
{
"text":"zip-test.zip",
"icon":"http://mfr.osf.io/assets/zip/img/file_ext_zip.png",
"children":[]
}
]
}
9 changes: 9 additions & 0 deletions tests/extensions/zip/fixtures/file_tree_empty.json
@@ -0,0 +1,9 @@
{
"file_tree":[
{
"text":"zip-empty.zip",
"icon":"http://mfr.osf.io/assets/zip/img/file_ext_zip.png",
"children":[]
}
]
}
117 changes: 0 additions & 117 deletions tests/extensions/zip/fixtures/fixtures.json

This file was deleted.

48 changes: 28 additions & 20 deletions tests/extensions/zip/test_renderer.py
@@ -1,13 +1,11 @@
import os
import re
import json
from zipfile import ZipFile

import pytest

from mfr.core.provider import ProviderMetadata
from mfr.extensions.zip import ZipRenderer

from mfr.core.provider import ProviderMetadata

BASE = os.path.dirname(os.path.abspath(__file__))

Expand All @@ -20,18 +18,27 @@ def metadata():
'1234',
'http://wb.osf.io/file/test.zip?token=1234')


@pytest.fixture
def zip_file():
return ZipFile(os.path.join(BASE, 'files', 'test.zip'), 'r')
return ZipFile(os.path.join(BASE, 'files', 'zip-test.zip'), 'r')


@pytest.fixture
def zip_file_tree():
return ZipFile(os.path.join(BASE, 'files', 'test-tree.zip'), 'r')
def zip_file_empty():
return ZipFile(os.path.join(BASE, 'files', 'zip-empty.zip'), 'r')


@pytest.fixture
def zip_empty_file():
return ZipFile(os.path.join(BASE, 'files', 'empty.zip'), 'r')
def expected_file_tree():
with open(os.path.join(os.path.dirname(__file__), 'fixtures/file_tree.json'), 'r') as fp:
return json.load(fp)['file_tree']


@pytest.fixture
def expected_file_tree_empty():
with open(os.path.join(os.path.dirname(__file__), 'fixtures/file_tree_empty.json'), 'r') as fp:
return json.load(fp)['file_tree']


@pytest.fixture
Expand Down Expand Up @@ -59,21 +66,22 @@ def renderer(metadata, test_file_path, url, assets_url, export_url):
return ZipRenderer(metadata, test_file_path, url, assets_url, export_url)


@pytest.fixture
def file_tree():
with open(os.path.join(os.path.dirname(__file__), 'fixtures/fixtures.json'), 'r') as fp:
return json.load(fp)['file_tree']


class TestZipRenderer:

def test_render(self, renderer):
body = renderer.render()
def test_render(self):
pass

def test_sanitize_obj_list(self):
pass

def test_filelist_to_tree(self, renderer, zip_file_tree, file_tree):
def test_find_node_among_siblings(self):
pass

files = [file for file in zip_file_tree.filelist if not file.filename.startswith('__MACOSX')]
def test_icon_exists(self):
pass

actual = renderer.filelist_to_tree(files)
assert actual == file_tree
def update_node_with_attributes(self):
pass

def test_obj_list_to_tree(self):
pass

0 comments on commit 1aaf11c

Please sign in to comment.