GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TestCsvToJsonConverter   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 31
Duplicated Lines 0 %
Metric Value
dl 0
loc 31
rs 10
wmc 9

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setup_method() 0 3 1
A test_run() 0 6 1
B test_complete_run() 0 14 7
1
# -*- coding: utf-8 -*-
2
3
import pytest
4
from mock import Mock
5
from mock import patch
6
7
import os
8
9
from csvToJsonConverter import csvToJsonConverter
10
11
class TestCsvToJsonConverter():
12
13
    # def teardown_method(self, method):
14
    #     #  teardown_method is invoked after every test method of a class
15
    #     self.csv_file.close()
16
17
    def setup_method(self, method):
18
        #  setup_method is invoked befor every test method of a class
19
        self.converter = csvToJsonConverter()
20
21
    def test_complete_run(self):
22
        result_path = "testData/test_result.json"
23
        try:
24
            os.remove(result_path)
25
        except OSError:
26
            pass
27
        assert os.path.isfile(result_path) == False
28
        self.converter.run("testData/test_for_jsonConverter.csv", result_path)
29
        assert os.path.isfile(result_path) == True
30
        with open("testData/expected_result.json", 'r') as expected_result_file:
31
            expected_result = expected_result_file.read()
32
        with open(result_path, 'r') as result_file:
33
            result = result_file.read()
34
        assert expected_result == result
35
36
    def test_run(self):
37
        self.converter.create_dump_list = Mock(return_value=[{"dumpListElement1"}, {"dumpListElement2"}])
38
        self.converter.write_dump_list_to_file = Mock()
39
        self.converter.run("csvPath", "jsonPath")
40
        self.converter.create_dump_list.assert_called_once_with("csvPath")
41
        self.converter.write_dump_list_to_file.assert_called_once_with([{"dumpListElement1"}, {"dumpListElement2"}], "jsonPath")