Пример #1
0
    def test_ShouldRaiseIOErrorIfNotJsonFile(self):
        json_loader = JsonLoader("plugins/some_plugin.json")
        json_loader.is_json_file = MagicMock(return_value=False)

        expect(lambda: json_loader.load()).to(raise_error(IOError))
Пример #2
0
    def test_ShouldReturnJsonDataIfIsJsonFile(self):
        json_loader = JsonLoader("plugins/some_plugin.json")
        json_loader.is_json_file = MagicMock(return_value=True)

        with patch('__builtin__.open', mock_open(read_data="{}"), create=True):
            expect(json_loader.load()).to(be_a(JsonData))
Пример #3
0
    def test_ShouldReturnFalseIfPathIsNotFile(self, isfile, exists):
        isfile.return_value = False
        exists.return_value = True
        json_loader = JsonLoader("plugins/some_plugin.json")

        expect(json_loader.is_json_file()).to(be_false)
Пример #4
0
    def test_ShouldReturnFalseIfPathNotFound(self, exists):
        exists.return_value = False
        json_loader = JsonLoader("plugins/some_plugin.json")

        expect(json_loader.is_json_file()).to(be_false)
Пример #5
0
    def test_ShouldReturnFalseIfNoJsonExtension(self):
        json_loader = JsonLoader("plugins/some_plugin.py")

        expect(json_loader.is_json_file()).to(be_false)
Пример #6
0
    def test_ShouldReturnTrueIfValidPath(self, isfile, exists):
        isfile.return_value = True
        exists.return_value = True
        json_loader = JsonLoader("plugins/some_plugin.json")

        expect(json_loader.is_json_file(fs_tools=os.path)).to(be_true)