Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
#1 added handler test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-kolda committed Jun 1, 2017
1 parent b95b448 commit b2a8250
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ before_install:
- pip install coveralls
- pip install pylint
script:
- find . -name "*.py" -path "./*" -not \( -path "./lib/*" -o -path "./google-cloud-sdk/*" \) | xargs pylint --reports=yes --rcfile=.pylintrc && coverage run --source=model test_runner.py --test-path tests/ -v --test-pattern test_m*.py ./google-cloud-sdk
- find . -name "*.py" -path "./*" -not \( -path "./lib/*" -o -path "./google-cloud-sdk/*" \) | xargs pylint --reports=yes --rcfile=.pylintrc && coverage run --source=model test_runner.py --test-path tests/ -v --test-pattern test_*.py ./google-cloud-sdk
after_success:
coveralls
39 changes: 39 additions & 0 deletions tests/test_model_creator_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import unittest

import webapp2

import webtest
from google.appengine.ext import testbed
from mock import patch

from model.model_creator import ModelCreator
from model.model_creator_handler import ModelCreatorHandler


class TestModelCreatorHandler(unittest.TestCase):

def setUp(self):
patch('googleapiclient.discovery.build').start()
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_memcache_stub()
app = webapp2.WSGIApplication(
[('/createModels', ModelCreatorHandler)]
)
self.under_test = webtest.TestApp(app)

def tearDown(self):
self.testbed.deactivate()
patch.stopall()

@patch.object(ModelCreator, 'create_missing_datasets')
@patch.object(ModelCreator, 'create_missing_models')
def test_happy_path(self, create_missing_models, create_missing_datasets):
# when
response = self.under_test.get(
'/createModels'
)
# then
self.assertEqual(response.status_int, 200)
create_missing_models.assert_called_once()
create_missing_datasets.assert_called_once()

0 comments on commit b2a8250

Please sign in to comment.