Ejemplo n.º 1
0
 def test_save(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     config.save()
     with open(self.folder + "bmc.json", 'r') as fh:
         read = json.loads(fh.read())
     self.assertEqual(read, config.as_dict())
Ejemplo n.º 2
0
 def test_load_with_file(self):
     config = self.default_config
     config["foo"] = "bar"
     with open(self.folder + "bmc.json", 'w') as fh:
         json.dump(config, fh)
     config_read = Config(base_config_path=self.folder)
     self.assertEqual(config, config_read.as_dict())
Ejemplo n.º 3
0
import argparse
import os
import shutil
import subprocess
import sys
import tempfile
import bibtexparser
from codecs import open
from libbmc.config import Config
from libbmc import backend
from libbmc import fetcher
from libbmc import tearpages
from libbmc import tools

config = Config()
EDITOR = os.environ.get('EDITOR') if os.environ.get('EDITOR') else 'vim'


def checkBibtex(filename, bibtex_string):
    print("The bibtex entry found for " + filename + " is:")

    bibtex = bibtexparser.loads(bibtex_string)
    bibtex = bibtex.entries_dict
    try:
        bibtex = bibtex[list(bibtex.keys())[0]]
        # Check entries are correct
        if "title" not in bibtex:
            raise AssertionError
        if "authors" not in bibtex and "author" not in bibtex:
            raise AssertionError
Ejemplo n.º 4
0
 def test_masks(self):
     with open(self.folder + "masks.py", 'w') as fh:
         fh.write("def f(x): return x")
     config = Config(base_config_path=self.folder)
     self.assertEqual("foo", config.get("format_custom")[0]("foo"))
Ejemplo n.º 5
0
 def test_set(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     self.assertEqual(config.get("foo"), "bar")
Ejemplo n.º 6
0
 def test_get(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.get("proxies"), [''])
Ejemplo n.º 7
0
 def test_load_without_file(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.as_dict(), self.default_config)
     with open(self.folder + "bmc.json", 'r') as fh:
         read = json.loads(fh.read())
     self.assertEqual(read, self.default_config)