-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
30 lines (22 loc) · 891 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import unittest
import pandas as pd
import requests
import os
class TestCSVData(unittest.TestCase):
def setUp(self):
self.df = pd.read_csv('data/data.csv', sep=';')
def test_unique_images(self):
images = self.df['image']
self.assertEqual(len(images), len(set(images)), "Not all images are unique")
def test_unique_urls(self):
urls = self.df['url']
self.assertEqual(len(urls), len(set(urls)), "Not all URLs are unique")
def test_urls_not_404(self):
for url in self.df['url']:
response = requests.get(url)
self.assertNotEqual(response.status_code, 404, f"URL {url} returned a 404")
def test_images_exist(self):
for image in self.df['image']:
self.assertTrue(os.path.exists('images/' + image), f"Image {image} does not exist")
if __name__ == "__main__":
unittest.main()