Пример #1
0
    def test_load_ezproxy_config_bails_on_no_json_filename(self,
                                                           load_json_file,
                                                           ospathexists):
        with mock.patch("os.listdir", return_value=["something.xml"]):
            output = load_ezproxy_config()

        # should still have returned a dictionary
        self.assertTrue(isinstance(output, dict))

        # should not have attempted to load xml file
        self.assertFalse(load_json_file.called)
Пример #2
0
    def test_load_ezproxy_config_loads_dict(self, oslistdir, ospathexists):
        testjson = {
            "url": "http://httpbin.org/",
            "data": {
                "User": "******",
                "pw": "91",
            },
        }

        with mock.patch("paperbot.ezproxy.load_json_file",
                        return_value=testjson):
            output = load_ezproxy_config()

        # should still be a dictionary result
        self.assertTrue(isinstance(output, dict))

        # but the dict should not be empty
        self.assertNotEqual(output, {})

        # this is based on listdir returning "test.json"
        self.assertTrue("test" in output.keys())

        # loaded config should be same as test config
        self.assertEqual(output["test"], testjson)
Пример #3
0
 def test_load_ezproxy_config_calls_file_reader(self, load_json_file,
                                                oslistdir, ospathexists):
     load_ezproxy_config()
     self.assertTrue(load_json_file.called)
Пример #4
0
 def test_load_ezproxy_config_path_does_not_exist(self):
     with mock.patch("os.path.exists", return_value=False) as ospathexists:
         load_ezproxy_config()
         self.assertTrue(ospathexists.called)