Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Insight tests #509

Merged
merged 1 commit into from

4 participants

@gnuwilliam

Adding tests for Insight. Was already closed, but not merged.

// @paulirish

@addyosmani
Owner

Looks good. Silly question - is there a reason the test-insight file is empty?

@gnuwilliam

@addyosmani This is just a personal pattern that I use for commits. Baby-steps, always. Even creating a file, I do a commit. If you need to revert, or change something, you'll see all the changes, step-by-step on your git log. :-)

@sindresorhus

@gnuwilliam git isn't cmd+s u know :P

Can you merge down the commits? We (I, I guess) prefer having a clean commit history.

But looks good to me otherwise.

@gnuwilliam gnuwilliam Adding test-insight file
Creating test for tracking code

Raising exception when no tracking_code is passed

Creating test for main
b595a2f
@gnuwilliam

@sindresorhus Hahaha, you know I have some git troubles. :-P

Anyway, done! I did merged the commits.

Thanks!

@gnuwilliam

@ebidel Hi Eric. Could you please review the tests? Then we can close the PR.

@ebidel
Owner

LGTM

@ebidel ebidel merged commit 2558702 into yeoman:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 20, 2012
  1. @gnuwilliam

    Adding test-insight file

    gnuwilliam authored
    Creating test for tracking code
    
    Raising exception when no tracking_code is passed
    
    Creating test for main
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 0 deletions.
  1. +3 −0  cli/bin/yeomaninsight.py
  2. +25 −0 cli/test/test-insight.py
View
3  cli/bin/yeomaninsight.py
@@ -31,6 +31,9 @@ class Analytics(object):
BASE_URL = 'http://www.google-analytics.com/collect/__utm.gif'
def __init__(self, tracking_code):
+ if not tracking_code:
+ raise Exception('No tracking code is given')
+
self.tracking_code = tracking_code
self.do_stats = True
View
25 cli/test/test-insight.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import sys
+import unittest
+import os
+
+sys.path.append('../bin/')
+
+from yeomaninsight import main, Analytics
+
+class YeomanInsightTest(unittest.TestCase):
+
+ def test_init_should_error_when_no_tracking_code_is_passed(self):
+ self.assertRaises(Exception, Analytics, tracking_code='')
+
+ def test_main_should_error_when_arguments_are_less_than_two(self):
+ # temporally disables print function, because it's used on main.
+ # just to keep the tests output clean.
+ sys.stdout = open(os.devnull, 'w')
+ self.assertRaises(SystemExit, main, args='')
+ # restores print function.
+ sys.stdout = sys.__stdout__
+
+if __name__ == '__main__':
+ unittest.main()
Something went wrong with that request. Please try again.