Skip to content

Commit

Permalink
Bump version: 0.0.0-b6 → 0.0.0-b7
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Mar 28, 2024
1 parent 0f58d27 commit b51d7fb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 32 deletions.
2 changes: 1 addition & 1 deletion bsb_json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

from .schema import get_json_schema, get_schema

__version__ = "0.0.0-b6"
__version__ = "0.0.0-b7"
7 changes: 1 addition & 6 deletions bsb_json/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
import os

import numpy as np
from bsb import (
ConfigurationParser,
ConfigurationWarning,
ParserError,
warn,
)
from bsb import ConfigurationParser, ConfigurationWarning, ParserError, warn


class JsonImportError(ParserError):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dev = [
profile = "black"

[tool.bumpversion]
current_version = "0.0.0-b6"
current_version = "0.0.0-b7"
parse = """(?x)
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
Expand Down
13 changes: 6 additions & 7 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import unittest
from tempfile import TemporaryFile

from bsb import config
from bsb.config import Configuration, from_json
from bsb.core import Scaffold
from bsb_test import RandomStorageFixture, get_test_config, get_test_config_tree
from bsb import Configuration, Scaffold, config, parse_configuration_file, \
parse_configuration_content
from bsb_test import RandomStorageFixture, get_test_config_tree


def as_json(name: str):
Expand All @@ -25,18 +24,18 @@ def test_json_minimal_bootstrap(self):
with TemporaryFile(mode="w+") as f:
f.write(as_json("minimal"))
f.seek(0)
config = from_json(f)
config = parse_configuration_file(f, parser="json")
Scaffold(config, self.storage)

def test_json_minimal_content_bootstrap(self):
config = from_json(data=as_json("minimal"))
config = parse_configuration_content(as_json("minimal"), parser="json")
Scaffold(config, self.storage)

def test_json_full_bootstrap(self):
with TemporaryFile(mode="w+") as f:
f.write(as_json("full_compile"))
f.seek(0)
config = from_json(f)
config = parse_configuration_file(f, parser="json")
Scaffold(config, self.storage)

@unittest.expectedFailure
Expand Down
34 changes: 17 additions & 17 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pathlib
import unittest

from bsb import config
from bsb.exceptions import *
from bsb_test import get_data_path
from bsb import ConfigurationWarning, PluginError, get_configuration_parser

from bsb_json.parser import JsonReferenceError


def get_content(file: str):
Expand All @@ -12,15 +12,15 @@ def get_content(file: str):

class TestJsonBasics(unittest.TestCase):
def test_get_parser(self):
config.get_parser("json")
self.assertRaises(PluginError, config.get_parser, "doesntexist")
get_configuration_parser("json")
self.assertRaises(PluginError, get_configuration_parser, "doesntexist")

def test_parse_empty_doc(self):
tree, meta = config.get_parser("json").parse(get_content("doc.json"))
tree, meta = get_configuration_parser("json").parse(get_content("doc.json"))
self.assertEqual({}, tree, "'doc.json' parse should produce empty dict")

def test_parse_basics(self):
tree, meta = config.get_parser("json").parse(get_content("basics.json"))
tree, meta = get_configuration_parser("json").parse(get_content("basics.json"))
self.assertEqual(3, tree["list"][2], "Incorrectly parsed basic JSON")
self.assertEqual(
"just like that",
Expand All @@ -34,7 +34,7 @@ def test_parse_basics(self):

class TestJsonRef(unittest.TestCase):
def test_indoc_reference(self):
tree, meta = config.get_parser("json").parse(get_content("intradoc_refs.json"))
tree, meta = get_configuration_parser("json").parse(get_content("intradoc_refs.json"))
self.assertNotIn("$ref", tree["refs"]["whats the"], "Ref key not removed")
self.assertEqual("key", tree["refs"]["whats the"]["secret"])
self.assertEqual("is hard", tree["refs"]["whats the"]["nested secrets"]["vim"])
Expand All @@ -43,12 +43,12 @@ def test_indoc_reference(self):
)
self.assertEqual(tree["refs"]["whats the"], tree["refs"]["omitted_doc"])
with self.assertRaises(JsonReferenceError, msg="Should raise 'ref not a dict'"):
tree, meta = config.get_parser("json").parse(
tree, meta = get_configuration_parser("json").parse(
get_content("intradoc_nodict_ref.json")
)

def test_far_references(self):
tree, meta = config.get_parser("json").parse(
tree, meta = get_configuration_parser("json").parse(
get_content("interdoc_refs.json"),
path=str(
(pathlib.Path(__file__).parent / "parser_tests" / "interdoc_refs.json")
Expand All @@ -60,15 +60,15 @@ def test_far_references(self):
self.assertEqual("just like that", tree["refs"]["whats the"]["oh yea"])

def test_double_ref(self):
tree, meta = config.get_parser("json").parse(
tree, meta = get_configuration_parser("json").parse(
get_content("doubleref.json"),
path=str(
(pathlib.Path(__file__).parent / "parser_tests" / "doubleref.json")
),
)

def test_ref_str(self):
parser = config.get_parser("json")
parser = get_configuration_parser("json")
tree, meta = parser.parse(
get_content("doubleref.json"),
path=str(
Expand All @@ -85,29 +85,29 @@ def test_ref_str(self):

class TestJsonImport(unittest.TestCase):
def test_indoc_import(self):
tree, meta = config.get_parser("json").parse(get_content("indoc_import.json"))
tree, meta = get_configuration_parser("json").parse(get_content("indoc_import.json"))
self.assertEqual(["with", "importable"], list(tree["imp"].keys()))
self.assertEqual("are", tree["imp"]["importable"]["dicts"]["that"])

def test_indoc_import_list(self):
from bsb_json.parser import parsed_list

tree, meta = config.get_parser("json").parse(
tree, meta = get_configuration_parser("json").parse(
get_content("indoc_import_list.json")
)
self.assertEqual(["with", "importable"], list(tree["imp"].keys()))
self.assertEqual("a", tree["imp"]["with"][0])
self.assertEqual(parsed_list, type(tree["imp"]["with"][2]), "message")

def test_indoc_import_value(self):
tree, meta = config.get_parser("json").parse(
tree, meta = get_configuration_parser("json").parse(
get_content("indoc_import_other.json")
)
self.assertEqual(["with", "importable"], list(tree["imp"].keys()))
self.assertEqual("a", tree["imp"]["with"])

def test_import_merge(self):
tree, meta = config.get_parser("json").parse(
tree, meta = get_configuration_parser("json").parse(
get_content("indoc_import_merge.json")
)
self.assertEqual(2, len(tree["imp"].keys()))
Expand All @@ -124,7 +124,7 @@ def test_import_merge(self):

def test_import_overwrite(self):
with self.assertWarns(ConfigurationWarning) as warning:
tree, meta = config.get_parser("json").parse(
tree, meta = get_configuration_parser("json").parse(
get_content("indoc_import_overwrite.json")
)
self.assertEqual(2, len(tree["imp"].keys()))
Expand Down

0 comments on commit b51d7fb

Please sign in to comment.