Add Repository and Package classes
This commit is contained in:
65
tests/test_repo_io.py
Executable file
65
tests/test_repo_io.py
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import json
|
||||
import blenderpack as BP
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(levelname)8s: %(message)s')
|
||||
|
||||
class TestRepoInstantiation(unittest.TestCase):
|
||||
"""
|
||||
Tests of the creation of a Repository object
|
||||
"""
|
||||
|
||||
# helper_path = Path('tests/test_helpers')
|
||||
# repos = blenderpack.Repositories(helper_path / 'repo.json')
|
||||
|
||||
# def test_load(self):
|
||||
# repo = self.repos.load('http://someurl.tld/repo.json')
|
||||
|
||||
repo_dict = {
|
||||
'name': 'The Best Repo Ever',
|
||||
'url': 'http://someurl.tld/repo.json',
|
||||
'packages': [
|
||||
{'name': 'pkg1'},
|
||||
{'name': 'pkg2'},
|
||||
],
|
||||
}
|
||||
|
||||
def test_create_from_dict(self):
|
||||
"""
|
||||
Instantiate repository repository with a dict and check
|
||||
if all the items are carried over
|
||||
"""
|
||||
repodict = self.repo_dict
|
||||
repo = BP.Repository(repodict)
|
||||
for key, val in repodict.items():
|
||||
self.assertEqual(getattr(repo, key), val)
|
||||
|
||||
def test_create_from_none(self):
|
||||
"""
|
||||
Instantiate repository repository from none and check that
|
||||
the new repository's properties are set to none
|
||||
"""
|
||||
repodict = self.repo_dict
|
||||
repo = BP.Repository(None)
|
||||
for key, val in repodict.items():
|
||||
self.assertEqual(getattr(repo, key), None)
|
||||
|
||||
def test_create_from_incomplete(self):
|
||||
"""
|
||||
Instantiate repository repository from a partial dict
|
||||
and check that all properties are set, either to None or to the
|
||||
value from the dict
|
||||
"""
|
||||
repodict = {
|
||||
'name': 'The Best Repo Ever',
|
||||
}
|
||||
repo = BP.Repository(repodict)
|
||||
for key, val in repodict.items():
|
||||
self.assertEqual(getattr(repo, key), val)
|
||||
self.assertIs(repo.url, None)
|
||||
|
Reference in New Issue
Block a user