-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_package.py
60 lines (46 loc) · 1.87 KB
/
test_package.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
(c) Peter Sefton 2016
This file is part of Netta.
Netta is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Netta is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Netta. If not, see <http://www.gnu.org/licenses/>.
"""
import unittest
import package
import shutil
import os
import glob
class TestLoading(unittest.TestCase):
def startup(self):
self.test_packages = os.path.join('tests', 'test_packages', "*.json")
self.temp_packages = os.path.join('tests', 'temp_packages')
for file in glob.glob(self.test_packages):
shutil.copy(file, self.temp_packages)
def test_simple_stufff(self):
self.startup()
path = os.path.join(self.temp_packages, "package1.json")
p = package.Package(path)
p.read()
self.assertEqual(p.id, "1")
self.assertEqual(p.name, "Package")
dirs = p.dirs
self.assertEqual(dirs[0].name, 'FOLDER 1')
files = p.files
self.assertEqual(len(files),0)
files = dirs[0].files
self.assertEqual(len(files),2)
files = p.all_files
self.assertEqual(len(files),5)
print(files[0].path)
bag = p.bag_me("test/bag1", overwrite=True, testmode=True)
#Test validity
p.zipped_bag("test/package1")
if __name__ == '__main__':
unittest.main()