Skip to content

Commit

Permalink
refactor: use absolute imports; move tests outside package
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Lor committed May 11, 2024
1 parent ca739ce commit 644e6dc
Show file tree
Hide file tree
Showing 25 changed files with 785 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find]
where = ["."]
include = ["vigobus"]
exclude = ["back_tools"]
exclude = ["back_tools", "docs", "tests", "tools"]

[tool.setuptools.dynamic]
dependencies = {file = ["vigobus/requirements.txt"]}
Empty file added tests/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from .fixers import Fixers
from vigobus.datasources.fixers import Fixers


@pytest.mark.parametrize("line, route, expected_line, expected_route", [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import pydantic
import pytest

from .ds_qrhtml import DatasourceQrHtml
from .. import Stop, StopMetadata, SourceMetadata
from ..conftest import TestMarks, Datetimes
from vigobus.datasources.ds_qrhtml import DatasourceQrHtml
from vigobus import Stop, StopMetadata, SourceMetadata
from tests.conftest import TestMarks, Datetimes


class MockDatasourceQrHtml(DatasourceQrHtml):
Expand Down
10 changes: 5 additions & 5 deletions vigobus/test_main.py → tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import freezegun
import pytest

from . import Stop, Position, StopMetadata, SourceMetadata, Vigobus
from .datasources.base import BaseDatasource
from .conftest import TestMarks, Datetimes
from .datasources.ds_qrhtml import DatasourceQrHtml
from .datasources.ds_vigoapi import DatasourceVigoApi
from vigobus import Stop, Position, StopMetadata, SourceMetadata, Vigobus
from vigobus.datasources.base import BaseDatasource
from tests.conftest import TestMarks, Datetimes
from vigobus.datasources.ds_qrhtml import DatasourceQrHtml
from vigobus.datasources.ds_vigoapi import DatasourceVigoApi


def test_vigobus_iter_datasources():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*
README.md
!README.md
!generate.sh
!testdata.zip
File renamed without changes.
124 changes: 124 additions & 0 deletions tests/tests_data/datasource_qrhtml_5800_buses_page1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Sistema Siam - Estimaciones Vitrasa
</title><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.5; user-scalable=1;" />


<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20267158-3']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>
<body bgcolor="#000000">
<form name="form1" method="post" action="Default.aspx?parada=5800" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUIMTY4MDc5NjkPZBYCAgMPZBYKAgEPDxYCHgRUZXh0BQQ1ODAwZGQCAw8PFgIfAAULSG9yYTogMTA6MzNkZAIFDw8WAh8ABR9Sw7phIGRlIEplbmFybyBkZSBsYSBGdWVudGUsIDI5ZGQCBw88KwANAQAPFgQeC18hRGF0YUJvdW5kZx4LXyFJdGVtQ291bnQCEGQWAmYPZBYMAgEPZBYGZg8PFgIfAAUBQWRkAgEPDxYCHwAFFFBPUlRPIC0gVU5JVkVSU0lEQURFZGQCAg8PFgIfAAUBNWRkAgIPZBYGZg8PFgIfAAUDMTVDZGQCAQ8PFgIfAAUeQXZkYS4gZGUgU2FtaWwgKGZyZW50ZSBWZXJidW0pZGQCAg8PFgIfAAUBOGRkAgMPZBYGZg8PFgIfAAUDMTVBZGQCAQ8PFgIfAAUXQXZkYS4gZGUgU2FtaWwgKFZlcmJ1bSlkZAICDw8WAh8ABQIxNWRkAgQPZBYGZg8PFgIfAAUCMTFkZAIBDw8WAh8ABRZTQU4gTUlHVUVMIHBvciBGTE9SSURBZGQCAg8PFgIfAAUCMTdkZAIFD2QWBmYPDxYCHwAFAUFkZAIBDw8WAh8ABSNBdmRhLiBkZSBHYXJjJiMyMzc7YSBCYXJiJiMyNDM7biwgN2RkAgIPDxYCHwAFAjMzZGQCBg8PFgIeB1Zpc2libGVoZGQCCQ8PZA8QFgFmFgEWAh4OUGFyYW1ldGVyVmFsdWUFBDU4MDAWAQIEZGQYAQUJR3JpZFZpZXcxDzwrAAoCBAUHTWludXRvcwgCBGRwRv4FySyNXQ17ECQvqPl+p/V5qQ==" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>


<div>

<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="CA0B0334" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBAKz3Yn7DAKtsp64BAKtsuK4BAKtsva4BK1k/4DD2FX3czWN7xM4BMPvkzxi" />
</div>
<div style="background-color: #000000">

<table style="width:300px;" align="center">
<tr>
<td>
&nbsp;</td>
<td align="center">
<img alt="" src="Images/logo.png" height="50" width="161"/><br />
<span id="lblParada" style="color:White;font-size:X-Small;">5800</span>
&nbsp;<span id="lblHora" style="color:White;font-size:X-Small;">Hora: 10:33</span>
<br />
<span id="lblNombre" style="color:White;font-size:Small;">Rúa de Jenaro de la Fuente, 29</span>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td align="center">
<div>
<table cellspacing="0" cellpadding="4" border="0" id="GridView1" style="color:#333333;border-collapse:collapse;">
<tr style="color:White;background-color:#5D7B9D;font-weight:bold;">
<th scope="col">L.</th><th scope="col">Ruta</th><th scope="col">Min.</th>
</tr><tr style="color:#333333;background-color:#F7F6F3;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">A</td><td align="left" style="font-size:Small;width:75%;">PORTO - UNIVERSIDADE</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">5</td>
</tr><tr style="color:#284775;background-color:White;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">15C</td><td align="left" style="font-size:Small;width:75%;">Avda. de Samil (frente Verbum)</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">8</td>
</tr><tr style="color:#333333;background-color:#F7F6F3;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">15A</td><td align="left" style="font-size:Small;width:75%;">Avda. de Samil (Verbum)</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">15</td>
</tr><tr style="color:#284775;background-color:White;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">11</td><td align="left" style="font-size:Small;width:75%;">SAN MIGUEL por FLORIDA</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">17</td>
</tr><tr style="color:#333333;background-color:#F7F6F3;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">A</td><td align="left" style="font-size:Small;width:75%;">Avda. de Garc&#237;a Barb&#243;n, 7</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">33</td>
</tr><tr align="center" style="color:White;background-color:#284775;">
<td colspan="3"><table border="0">
<tr>
<td><span>1</span></td><td><a href="javascript:__doPostBack('GridView1','Page$2')" style="color:White;">2</a></td><td><a href="javascript:__doPostBack('GridView1','Page$3')" style="color:White;">3</a></td><td><a href="javascript:__doPostBack('GridView1','Page$4')" style="color:White;">4</a></td>
</tr>
</table></td>
</tr>
</table>
</div>


</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td align="center">
<img alt="" src="Images/logo_siam.png" height="50" width="128"/>
&nbsp; &nbsp; &nbsp;
<a href="https://hoxe.vigo.org/actualidade/app_vigo.php?lang=gal#/"><img src="Images/logovigoapp.png" height="72" width="72"></a>
<!-- <<a href="https://hoxe.vigo.org/actualidade/app_vigo.php?lang=gal#/"><img src="Images/logovigoapp.png" height="72" width="72"></a> -->
</td>
<td>
&nbsp;</td>


</tr>

</table>

</div>
</form>
</body>
</html>
124 changes: 124 additions & 0 deletions tests/tests_data/datasource_qrhtml_5800_buses_page2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
Sistema Siam - Estimaciones Vitrasa
</title><meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.5; user-scalable=1;" />


<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20267158-3']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>
<body bgcolor="#000000">
<form name="form1" method="post" action="Default.aspx?parada=5800" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUIMTY4MDc5NjkPZBYCAgMPZBYKAgEPDxYCHgRUZXh0BQQ1ODAwZGQCAw8PFgIfAAULSG9yYTogMTA6MzRkZAIFDw8WAh8ABR9Sw7phIGRlIEplbmFybyBkZSBsYSBGdWVudGUsIDI5ZGQCBw88KwANAQAPFgQeC18hRGF0YUJvdW5kZx4LXyFJdGVtQ291bnQCEGQWAmYPZBYMAgEPZBYGZg8PFgIfAAUDMTVCZGQCAQ8PFgIfAAUeQXZkYS4gZGUgU2FtaWwgKGZyZW50ZSBWZXJidW0pZGQCAg8PFgIfAAUCMzNkZAICD2QWBmYPDxYCHwAFAjRBZGQCAQ8PFgIfAAUTICBDT0lBIHBvciBDQVNURUxBT2RkAgIPDxYCHwAFAjM5ZGQCAw9kFgZmDw8WAh8ABQMxNUFkZAIBDw8WAh8ABRdBdmRhLiBkZSBTYW1pbCAoVmVyYnVtKWRkAgIPDxYCHwAFAjQ3ZGQCBA9kFgZmDw8WAh8ABQIxMWRkAgEPDxYCHwAFFlNBTiBNSUdVRUwgcG9yIEZMT1JJREFkZAICDw8WAh8ABQI0OWRkAgUPZBYGZg8PFgIfAAUCOUJkZAIBDw8WAh8ABQVDT0xPTmRkAgIPDxYCHwAFAjUxZGQCBg8PFgIeB1Zpc2libGVoZGQCCQ8PZA8QFgFmFgEWAh4OUGFyYW1ldGVyVmFsdWUFBDU4MDAWAQIEZGQYAQUJR3JpZFZpZXcxDxQrAApkZAIBZAUHTWludXRvc2RkZAIEZGTzCuE5J78J1BxKO8CGOLF/TrlWlw==" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>


<div>

<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="CA0B0334" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBAKhnoPKCwKtsuq4BAKtsuK4BAKtsva4BKQNqNXtXZHgznu/0Sw8crp/D3dX" />
</div>
<div style="background-color: #000000">

<table style="width:300px;" align="center">
<tr>
<td>
&nbsp;</td>
<td align="center">
<img alt="" src="Images/logo.png" height="50" width="161"/><br />
<span id="lblParada" style="color:White;font-size:X-Small;">5800</span>
&nbsp;<span id="lblHora" style="color:White;font-size:X-Small;">Hora: 10:34</span>
<br />
<span id="lblNombre" style="color:White;font-size:Small;">Rúa de Jenaro de la Fuente, 29</span>
</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td align="center">
<div>
<table cellspacing="0" cellpadding="4" border="0" id="GridView1" style="color:#333333;border-collapse:collapse;">
<tr style="color:White;background-color:#5D7B9D;font-weight:bold;">
<th scope="col">L.</th><th scope="col">Ruta</th><th scope="col">Min.</th>
</tr><tr style="color:#333333;background-color:#F7F6F3;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">15B</td><td align="left" style="font-size:Small;width:75%;">Avda. de Samil (frente Verbum)</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">33</td>
</tr><tr style="color:#284775;background-color:White;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">4A</td><td align="left" style="font-size:Small;width:75%;"> COIA por CASTELAO</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">39</td>
</tr><tr style="color:#333333;background-color:#F7F6F3;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">15A</td><td align="left" style="font-size:Small;width:75%;">Avda. de Samil (Verbum)</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">47</td>
</tr><tr style="color:#284775;background-color:White;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">11</td><td align="left" style="font-size:Small;width:75%;">SAN MIGUEL por FLORIDA</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">49</td>
</tr><tr style="color:#333333;background-color:#F7F6F3;">
<td align="left" style="font-size:Small;font-weight:normal;width:15%;">9B</td><td align="left" style="font-size:Small;width:75%;">COLON</td><td align="right" style="font-size:Small;font-weight:normal;width:10%;">51</td>
</tr><tr align="center" style="color:White;background-color:#284775;">
<td colspan="3"><table border="0">
<tr>
<td><a href="javascript:__doPostBack('GridView1','Page$1')" style="color:White;">1</a></td><td><span>2</span></td><td><a href="javascript:__doPostBack('GridView1','Page$3')" style="color:White;">3</a></td><td><a href="javascript:__doPostBack('GridView1','Page$4')" style="color:White;">4</a></td>
</tr>
</table></td>
</tr>
</table>
</div>


</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td align="center">
<img alt="" src="Images/logo_siam.png" height="50" width="128"/>
&nbsp; &nbsp; &nbsp;
<a href="https://hoxe.vigo.org/actualidade/app_vigo.php?lang=gal#/"><img src="Images/logovigoapp.png" height="72" width="72"></a>
<!-- <<a href="https://hoxe.vigo.org/actualidade/app_vigo.php?lang=gal#/"><img src="Images/logovigoapp.png" height="72" width="72"></a> -->
</td>
<td>
&nbsp;</td>


</tr>

</table>

</div>
</form>
</body>
</html>
Loading

0 comments on commit 644e6dc

Please sign in to comment.