예제 #1
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))
예제 #2
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
        )
예제 #3
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))
예제 #4
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))
예제 #5
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)
예제 #6
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)
예제 #7
0
    def test_ShouldReturnFalseIfNoJsonExtension(self):
        json_loader = JsonLoader("plugins/some_plugin.py")

        expect(json_loader.is_json_file()).to(be_false)
예제 #8
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)
예제 #9
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))
예제 #10
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)
예제 #11
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)
예제 #12
0
    def test_ShouldReturnFalseIfNoJsonExtension(self):
        json_loader = JsonLoader("plugins/some_plugin.py")

        expect(json_loader.is_json_file()).to(be_false)