Skip to content

Commit dee12f5

Browse files
committed
Remove automatic undercutter
1 parent 2aa1892 commit dee12f5

23 files changed

+98
-578
lines changed

.coveragerc

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[report]
2+
show_missing = True
3+
4+
exclude_lines =
5+
pragma: no cover
6+
7+
# Don't complain about missing debug-only code:
8+
def __unicode__
9+
def __repr__
10+
if self\.debug
11+
12+
# Don't complain if tests don't hit defensive assertion code:
13+
raise AssertionError
14+
raise NotImplementedError
15+
16+
# Don't complain if non-runnable code isn't run:
17+
if 0:
18+
if __name__ == .__main__.:
19+
20+
omit =
21+
*/tests/*
22+
*/migrations/*
23+
*/urls.py
24+
*/settings/*
25+
*/wsgi.py
26+
manage.py
27+
fabfile.py

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,6 @@ pip-selfcheck.json
284284
# SonarLint working directories, configuration files (including credentials)
285285
.sonarlint/
286286

287-
# End of https://www.gitignore.io/api/python,django,pycharm,sonarqube
287+
# End of https://www.gitignore.io/api/python,django,pycharm,sonarqube
288+
289+
migrations/

.idea/VasSite.iml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dataSources.xml

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sqldialects.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VasSite/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
# Application definition
3131

3232
INSTALLED_APPS = [
33-
'website',
3433
'django.contrib.admin',
3534
'django.contrib.auth',
3635
'django.contrib.contenttypes',
3736
'django.contrib.sessions',
3837
'django.contrib.messages',
3938
'django.contrib.staticfiles',
4039
'django.contrib.humanize',
40+
'website.apps.WebsiteConfig',
4141
'website.templatetags.kwacros',
4242
]
4343

templates/website/auto_undercutter.html

-9
This file was deleted.

templates/website/base.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
{% load staticfiles %}
2-
3-
<!DOCTYPE html>
1+
{% load staticfiles %}<!DOCTYPE html>
42
<html lang="en">
53

64
<head>

templates/website/includes/auto_undercutter/auto-fraction-card.html

-54
This file was deleted.

templates/website/includes/auto_undercutter/auto-fraction-form.html

-47
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<li><a href="{% url 'index' %}">Home</a></li>
22
<li><a href="{% url 'undercutter' %}">Undercutter</a></li>
3-
<li><a href="{% url 'auto_undercutter' %}">Auto Undercutter</a></li>
43
<li><a href="{% url 'program_scraper' %}">TVR Program Scraper</a></li>

website/forms.py

-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from collections import deque
2-
31
from django import forms
4-
from website.utils import utils
52

63

74
class FractionForm(forms.Form):
@@ -22,34 +19,6 @@ def clean(self):
2219
return cleaned_data
2320

2421

25-
class AutoFractionForm(forms.Form):
26-
choices = [(currency, currency) for currency in utils.get_currency_names()]
27-
leagues = deque([(league, league) for league in utils.get_trade_league_names()])
28-
leagues.rotate(2)
29-
currency_sell = forms.ChoiceField(choices=choices)
30-
currency_buy = forms.ChoiceField(choices=choices)
31-
max_numerator = forms.IntegerField(min_value=1)
32-
max_denominator = forms.IntegerField(min_value=1)
33-
league = forms.ChoiceField(choices=leagues)
34-
account_name = forms.CharField()
35-
api_key = forms.CharField()
36-
37-
def clean(self):
38-
cleaned_data = super(AutoFractionForm, self).clean()
39-
currency_sell = cleaned_data.get('currency_sell')
40-
currency_buy = cleaned_data.get('currency_buy')
41-
max_numerator = cleaned_data.get('max_numerator')
42-
max_denominator = cleaned_data.get('max_denominator')
43-
league = cleaned_data.get('league')
44-
account_name = cleaned_data.get('account_name')
45-
api_key = cleaned_data.get('api_key')
46-
47-
if not max_numerator and not max_denominator or not league or not currency_buy or not currency_sell or not account_name or not api_key:
48-
raise forms.ValidationError('You have to write something!')
49-
50-
return cleaned_data
51-
52-
5322
class ScraperForm(forms.Form):
5423
name = forms.CharField()
5524
type = forms.CharField()

website/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from django.db import models
21

3-
# Create your models here.
2+
3+
File renamed without changes.

website/tests.py website/tests/tests.py

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
from django.test import TestCase
2-
from website.utils.ratio_calculator import Calculation
31
from fractions import Fraction
2+
3+
from django.test import TestCase
4+
45
from website.utils import utils
6+
from website.utils.ratio_calculator import Calculation
7+
8+
9+
class IndexTest(TestCase):
10+
def test_index_returns_correct_html(self):
11+
response = self.client.get('/')
12+
self.assertTemplateUsed(response, 'website/homepage.html')
513

614

715
class CalculationTestCase(TestCase):
@@ -11,18 +19,18 @@ def test_normal_ratio(self):
1119
data = Calculation(188, 55, 10, 4, self.limit, self.limit).run()
1220
self.assert_empty(data)
1321
self.assert_has_simplifiable_terms(data)
14-
self.assert_not_nth_element(data, 0, 188, 55)
15-
self.assert_nth_element(data, 0, 41, 12)
16-
self.assert_nth_element(data, 9, 44, 13)
22+
self.assert_not_nth_element(data, 1, 188, 55)
23+
self.assert_nth_element(data, 1, 65, 19)
24+
self.assert_nth_element(data, 10, 38, 11)
1725
self.assertTrue(data['fractions'][0]['ratio'] > 1)
1826

1927
def test_inverse_ratio(self):
2028
inverse_data = Calculation(55, 188, 10, 4, self.limit, self.limit).run()
2129
self.assert_empty(inverse_data)
2230
self.assert_has_simplifiable_terms(inverse_data)
23-
self.assert_not_nth_element(inverse_data, 0, 55, 188)
24-
self.assert_nth_element(inverse_data, 0, 19, 65)
25-
self.assert_nth_element(inverse_data, 9, 11, 38)
31+
self.assert_not_nth_element(inverse_data, 1, 55, 188)
32+
self.assert_nth_element(inverse_data, 1, 12, 41)
33+
self.assert_nth_element(inverse_data, 10, 13, 44)
2634
self.assertTrue(inverse_data['fractions'][0]['ratio'] < 1)
2735

2836
def test_other(self):
@@ -31,10 +39,10 @@ def test_other(self):
3139
data1 = Calculation(1, 7, 10, 4, self.limit, self.limit).run()
3240
self.assert_empty(data1)
3341
self.assert_has_simplifiable_terms(data1)
34-
self.assert_not_nth_element(data1, 0, 1, 7)
35-
self.assert_nth_element(data1, 0, 14, 99)
36-
self.assert_nth_element(data1, 8, 13, 93)
37-
self.assert_nth_element(data1, 9, 6, 43)
42+
self.assert_not_nth_element(data1, 1, 1, 7)
43+
self.assert_nth_element(data1, 1, 14, 97)
44+
self.assert_nth_element(data1, 9, 13, 89)
45+
self.assert_nth_element(data1, 10, 6, 41)
3846

3947
def test_humanize_seconds(self):
4048
self.assertEqual(utils.humanize_seconds(654321.123456), '181 hours, 45 minutes, 21 seconds, 123 milliseconds and 456 microseconds')
@@ -50,10 +58,7 @@ def assert_nth_element(self, data, n, numerator_result, denominator_result):
5058
self.assertTrue(data['fractions'][n]['numerator'] == numerator_result and data['fractions'][n]['denominator'] == denominator_result, f'Element {n} is {data["fractions"][n]["numerator"]}/{data["fractions"][n]["denominator"]} instead of {numerator_result}/{denominator_result}')
5159

5260
def assert_not_nth_element(self, data, n, numerator_result, denominator_result):
53-
self.assertFalse(data['fractions'][n]['numerator'] == numerator_result and data['fractions'][n]['denominator'] == denominator_result, f'Element {n} shouldn\'t be {numerator_result} / {denominator_result} in {data["fractions"]}')
61+
self.assertFalse(data['fractions'][n]['numerator'] == numerator_result and data['fractions'][n]['denominator'] == denominator_result, f'Element {n} shouldn\'t be {numerator_result} / {denominator_result} in {0}')
5462

5563
def assert_empty(self, data):
5664
self.assertTrue(utils.is_empty(data), f'The list is empty')
57-
58-
def assert_not_empty(self, data):
59-
self.assertFalse(utils.is_empty(data), f'The list is not empty')

website/tests/tests_functional.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from django.test import TestCase
2+
from selenium import webdriver
3+
4+
5+
class NewVisitorTest(TestCase):
6+
def setUp(self):
7+
self.browser = webdriver.Chrome()
8+
9+
def tearDown(self):
10+
self.browser.quit()
11+
12+
def test_see_browser(self):
13+
self.browser.get('http://localhost:8000')
14+
15+
self.assertIn('Undercut', self.browser.title)

website/urls.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from django.conf.urls import url
2+
23
from . import views
34

45
urlpatterns = [
5-
url('auto-undercutter/', views.auto_undercutter, name='auto_undercutter'),
66
url('undercutter/', views.undercutter, name='undercutter'),
77
url('program-scraper/', views.program_scraper, name='program_scraper'),
88
url('', views.index, name='index')

0 commit comments

Comments
 (0)