This repository has been archived on 2023-02-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-package-manager-addon/tests/test_repo_io.py
gandalf3 bbc1c8b3bf Rename "blenderpack" module to "bpackage"
Also split code into files by class
2017-07-06 22:58:17 -07:00

66 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python3
import unittest
from pathlib import Path
import logging
import json
import bpackage 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)