|
|
@@ -7,18 +7,18 @@ from oscar.test import ClientTestCase
|
|
7
|
7
|
from oscar.test.helpers import create_order
|
|
8
|
8
|
|
|
9
|
9
|
|
|
10
|
|
-class AnonymousUserTests(ClientTestCase):
|
|
|
10
|
+class TestDashboardIndexForAnonUser(ClientTestCase):
|
|
11
|
11
|
is_anonymous = True
|
|
12
|
12
|
|
|
13
|
|
- def test_login_form_is_displayed_for_anon_user(self):
|
|
|
13
|
+ def test_is_not_available(self):
|
|
14
|
14
|
response = self.client.get(reverse('dashboard:index'), follow=True)
|
|
15
|
15
|
self.assertContains(response, 'login-username', status_code=200)
|
|
16
|
16
|
|
|
17
|
17
|
|
|
18
|
|
-class DashboardViewTests(ClientTestCase):
|
|
|
18
|
+class TestDashboardIndexForStaffUser(ClientTestCase):
|
|
19
|
19
|
is_staff = True
|
|
20
|
20
|
|
|
21
|
|
- def test_dashboard_index_is_for_staff_only(self):
|
|
|
21
|
+ def test_is_available(self):
|
|
22
|
22
|
urls = ('dashboard:index',
|
|
23
|
23
|
'dashboard:order-list',
|
|
24
|
24
|
'dashboard:users-index',)
|
|
|
@@ -26,7 +26,7 @@ class DashboardViewTests(ClientTestCase):
|
|
26
|
26
|
response = self.client.get(reverse(name))
|
|
27
|
27
|
self.assertTrue('Password' not in response.content)
|
|
28
|
28
|
|
|
29
|
|
- def test_dashboard_hourly_report_with_no_orders(self):
|
|
|
29
|
+ def test_includes_hourly_report_with_no_orders(self):
|
|
30
|
30
|
report = IndexView().get_hourly_report()
|
|
31
|
31
|
self.assertItemsEqual(report, ['order_total_hourly', 'max_revenue',
|
|
32
|
32
|
'y_range'])
|
|
|
@@ -34,7 +34,7 @@ class DashboardViewTests(ClientTestCase):
|
|
34
|
34
|
self.assertEquals(len(report['y_range']), 0)
|
|
35
|
35
|
self.assertEquals(report['max_revenue'], 0)
|
|
36
|
36
|
|
|
37
|
|
- def test_dashboard_hourly_report_with_orders(self):
|
|
|
37
|
+ def test_includes_hourly_report_with_orders(self):
|
|
38
|
38
|
create_order(total_incl_tax=D('34.05'), total_excl_tax=D('34.05'))
|
|
39
|
39
|
create_order(total_incl_tax=D('21.90'), total_excl_tax=D('21.90'))
|
|
40
|
40
|
report = IndexView().get_hourly_report()
|
|
|
@@ -43,7 +43,7 @@ class DashboardViewTests(ClientTestCase):
|
|
43
|
43
|
self.assertEquals(len(report['y_range']), 11)
|
|
44
|
44
|
self.assertEquals(report['max_revenue'], D('60'))
|
|
45
|
45
|
|
|
46
|
|
- def test_dashboard_index_has_stats_vars_in_context(self):
|
|
|
46
|
+ def test_has_stats_vars_in_context(self):
|
|
47
|
47
|
response = self.client.get(reverse('dashboard:index'))
|
|
48
|
48
|
|
|
49
|
49
|
self.assertInContext(response, 'total_orders_last_day')
|