| Total Complexity | 4 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | #!/usr/bin/python |
||
| 15 | class TestInit(unittest.TestCase): |
||
| 16 | SAUCENAO_MIN_WIDTH = 3 |
||
| 17 | SAUCENAO_MIN_HEIGHT = 3 |
||
| 18 | |||
| 19 | def setUp(self): |
||
| 20 | """Constructor for unittest classes |
||
| 21 | |||
| 22 | :return: |
||
| 23 | """ |
||
| 24 | directory = str(uuid4()) |
||
| 25 | os.mkdir(directory) |
||
| 26 | self.directory = os.path.abspath(directory) |
||
| 27 | self.generate_small_jpg() |
||
| 28 | |||
| 29 | def tearDown(self): |
||
| 30 | """Destructor for unittest classes |
||
| 31 | |||
| 32 | :return: |
||
| 33 | """ |
||
| 34 | shutil.rmtree(self.directory) |
||
| 35 | |||
| 36 | def generate_small_jpg(self): |
||
| 37 | """Generate a rather small jpg file to upload faster(631 bytes) |
||
| 38 | |||
| 39 | :return: |
||
| 40 | """ |
||
| 41 | file_path = str(uuid4()) + ".jpg" |
||
| 42 | im = Image.new("RGB", (self.SAUCENAO_MIN_WIDTH, self.SAUCENAO_MIN_HEIGHT)) |
||
| 43 | im.save(os.path.join(self.directory, file_path), "JPEG") |
||
| 44 | return file_path |
||
| 45 | |||
| 46 | def test_run_application(self): |
||
| 47 | """Test the run_application function |
||
| 48 | |||
| 49 | :return: |
||
| 50 | """ |
||
| 51 | sys.argv = [sys.argv[0], '-d', self.directory] |
||
| 52 | run_application() |
||
| 53 | |||
| 58 |