Changeset d6f8304 in OpenWorkouts-current for ow/tests/models/test_workout.py
- Timestamp:
- Feb 11, 2019, 6:55:55 PM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- 02aee97
- Parents:
- 93bbb89
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/tests/models/test_workout.py
r93bbb89 rd6f8304 7 7 import pytest 8 8 from pyramid.security import Allow, Everyone, Deny, ALL_PERMISSIONS 9 from pyramid.testing import DummyRequest 9 10 10 11 from ow.models.workout import Workout … … 576 577 def test_map_screenshot_no_gpx(self, sms, os, root): 577 578 workout = root['john']['1'] 578 assert workout.map_screenshot is None 579 request = DummyRequest() 580 assert workout.map_screenshot(request) is None 579 581 assert not os.path.abspath.called 580 582 assert not os.path.dirname.called … … 602 604 603 605 uid = str(root['john'].uid) 604 assert workout.map_screenshot == 'ow:/static/maps/' + uid + '/1.png' 606 request = DummyRequest() 607 # dummyrequest can't resolve static assets without adding a lot 608 # of boilerplate, no need for that here 609 request.static_url = Mock() 610 request.static_url.return_value = 'ow:/static/maps/' + uid + '/1.png' 611 res = workout.map_screenshot(request) 612 assert res == 'ow:/static/maps/' + uid + '/1.png' 605 613 assert os.path.abspath.called 606 614 assert os.path.dirname.called 607 assert os.path.join.call_count == 2615 assert os.path.join.call_count == 3 608 616 assert os.path.exists.called 609 sms.assert_called_once_with(workout )617 sms.assert_called_once_with(workout, request) 610 618 611 619 @patch('ow.models.workout.os') … … 619 627 os.path.join.side_effect = join 620 628 # This forces the "save screenshot" code NOT to be run 621 os.path.e xists.return_value = True629 os.path.eisxts.return_value = True 622 630 623 631 workout = root['john']['1'] … … 626 634 627 635 uid = str(root['john'].uid) 628 assert workout.map_screenshot == 'ow:/static/maps/' + uid + '/1.png' 636 request = DummyRequest() 637 # dummyrequest can't resolve static assets without adding a lot 638 # of boilerplate, no need for that here 639 request.static_url = Mock() 640 request.static_url.return_value = 'ow:/static/maps/' + uid + '/1.png' 641 res = workout.map_screenshot(request) 642 assert res == 'ow:/static/maps/' + uid + '/1.png' 629 643 assert os.path.abspath.called 630 644 assert os.path.dirname.called 631 assert os.path.join.call_count == 2645 assert os.path.join.call_count == 3 632 646 assert os.path.exists.called 633 647 assert not sms.called
Note: See TracChangeset
for help on using the changeset viewer.