Beispiel #1
0
    def test_set_extensions(self):
        with open(self.readme_file, "w") as f:
            json.dump({}, f)

        kwargs = dict(extensions=["com", "org"],
                      outputsubfolder="foo",
                      numberofrules=5,
                      sourcesdata="hosts")
        update_readme_data(self.readme_file, **kwargs)

        expected = {
            "com-org": {
                "location": "foo" + self.sep,
                "sourcesdata": "hosts",
                "entries": 5,
            }
        }

        with open(self.readme_file, "r") as f:
            actual = json.load(f)
            self.assertEqual(actual, expected)
Beispiel #2
0
    def test_modify_fields(self):
        with open(self.readme_file, "w") as f:
            json.dump({"base": "soprano"}, f)

        kwargs = dict(extensions=None,
                      outputsubfolder="foo",
                      numberofrules=5,
                      sourcesdata="hosts")
        update_readme_data(self.readme_file, **kwargs)

        expected = {
            "base": {
                "location": "foo" + self.sep,
                "sourcesdata": "hosts",
                "entries": 5,
            }
        }

        with open(self.readme_file, "r") as f:
            actual = json.load(f)
            self.assertEqual(actual, expected)