Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated check.py test script using pytest #80

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ dist
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# python
.pytest_cache/
__pycache__/
.pyc

# IntelliJ IDEA
.idea

34 changes: 0 additions & 34 deletions check.py

This file was deleted.

2 changes: 1 addition & 1 deletion public/flights/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

gtag('config', 'UA-153454345-1');
</script>
<script src="../js/embed.js"></script>
<meta charset="utf-8">

<title>מפת הקורונה של ישראל</title>
Expand All @@ -37,6 +36,7 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<!--========== page-specific files ==========-->
<script src="../js/embed.js"></script>
ofer1katz marked this conversation as resolved.
Show resolved Hide resolved
<link rel="stylesheet" href="../css/info.css" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="../css/styles.css" />
Expand Down
32 changes: 15 additions & 17 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,41 @@
</script>
<meta charset="utf-8">

<link rel="canonical" href="https://israelcoronamap.co.il/">

<title>מפת הקורונה של ישראל</title>

<link rel="icon" href="data:;base64,iVBORw0KGgo=">

<!--========== script ==========-->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>

<script src="languages/He.js"></script>
<script src="languages/En.js"></script>
<script src="languages/Ar.js"></script>
<script src="languages/Ru.js"></script>
<script src="languages/i18n.js"></script>
<script src="js/app.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBUJdl2h2JqN7NWOUKgG05emvLRY57-Fpg&callback=initMap" async defer></script>
<!--========== script end ==========-->


<!--========== web tags ==========-->
<meta name="description" content="מפת הקורונה של ישראל" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="google-site-verification" content="QCadyck7Ws0MzeYVe3Cv0FPZxf2r--5fSd2CznTwi4Y" />

<!--========== social media tags ==========-->

<meta property="og:title" content="מפת הקורונה של ישראל" />
<meta property="og:description" content="בדקו היכן ומתי שהו חולי קורונה מאומתים בישראל, בקלות ובמהירות באמצעות מפת הקורונה של ישראל" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://israelcoronamap.co.il/" />
<meta property="og:image" content="https://israelcoronamap.co.il/assets/images/social-img.png" />

<!--========== goolge fonts ==========-->
<!--========== Google fonts ==========-->
<link href="https://fonts.googleapis.com/css?family=Assistant:200,300,400,600,700,800" rel="stylesheet">

<!--========== css files ==========-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<!--========== page-specific files ==========-->

<!--========== script ==========-->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="languages/He.js"></script>
<script src="languages/En.js"></script>
<script src="languages/Ar.js"></script>
<script src="languages/i18n.js"></script>
<script src="js/app.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBUJdl2h2JqN7NWOUKgG05emvLRY57-Fpg&callback=initMap" async defer></script>
<!--========== script end ==========-->

<link rel="canonical" href="https://israelcoronamap.co.il/">
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/embed.css" />
<link rel="stylesheet" href="css/map.css" />
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bs4>=0.0.1
requests>=2.23.0
pytest>=4.6.5
36 changes: 36 additions & 0 deletions test/test_canonical_head.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from bs4 import BeautifulSoup
import pytest
import os


os.chdir('..')

def get_html_files():
result = []
for root, dirs, files in os.walk('public'):
for f in files:
if f.endswith('.html'):
result.append(os.path.join(root, f))
return result

def get_file_content(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
return f.read()

def get_head(html_contents):
soup = BeautifulSoup(html_contents, 'html.parser')
return soup.head

def extract_canonical_head(head):
head = str(head)
head = head[:head.index('<!--========== page-specific files ==========-->')]
return head

# An example of how the head should look like
CANONICAL_HEAD = extract_canonical_head(get_head(get_file_content(os.path.join('public', 'index.html'))))

# Run the test for each html file contains a head tag
@pytest.mark.parametrize('filepath', filter(lambda filepath: get_head(get_file_content(filepath)), get_html_files()))
def test_canonical_head(filepath):
head = extract_canonical_head(get_head(get_file_content(filepath)))
assert head == CANONICAL_HEAD, 'mean head differs with ' + filepath