Skip to content

Commit

Permalink
Added drange test and .travis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tinybike committed Aug 25, 2015
1 parent ac3ba5f commit 02af7c5
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: python
notifications:
email: true
python:
- "2.6"
- "2.7"
install:
- "sudo apt-get install freetds-dev python-numpy python-matplotlib python-scipy python-pymssql -qq -y"
- "easy_install -U setuptools"
- "pip install --upgrade pip"
- "pip install -r requirements.txt"
- "pip install -r test_requirements.txt"
script:
- py.test test/test_glitch.py --doctest-modules -v --cov glitch --cov-report term-missing
after_success:
- coveralls
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
READ ME -- Glitch.py
Glitch.py
=========

[![Build Status](https://travis-ci.org/tinybike/glitch.svg)](https://travis-ci.org/tinybike/glitch)
[![Coverage Status](https://coveralls.io/repos/tinybike/glitch/badge.svg?branch=master&service=github)](https://coveralls.io/github/tinybike/glitch?branch=master)

BASIC INSTRUCTIONS TO RUN GLITCH AS A ONE-HIT FUNCTION ON CMD LINE:

Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
numpy
matplotlib
pymssql
requests
72 changes: 72 additions & 0 deletions test/test_glitch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python
"""
Glitch unit tests
"""
import os
import platform
import csv
import time
import datetime
import itertools
import sys
import math
import types

HERE = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(HERE, os.pardir))

import glitch

def test_drange():
expected = [
"2012-10-10 01:01:00",
"2012-10-20 01:01:00",
"2012-10-30 01:01:00",
"2012-11-09 01:01:00",
"2012-11-19 01:01:00",
"2012-11-29 01:01:00",
"2012-12-09 01:01:00",
"2012-12-19 01:01:00",
"2012-12-29 01:01:00",
"2013-01-08 01:01:00",
"2013-01-18 01:01:00",
"2013-01-28 01:01:00",
"2013-02-07 01:01:00",
"2013-02-17 01:01:00",
"2013-02-27 01:01:00",
"2013-03-09 01:01:00",
"2013-03-19 01:01:00",
"2013-03-29 01:01:00",
"2013-04-08 01:01:00",
"2013-04-18 01:01:00",
"2013-04-28 01:01:00",
"2013-05-08 01:01:00",
"2013-05-18 01:01:00",
"2013-05-28 01:01:00",
"2013-06-07 01:01:00",
"2013-06-17 01:01:00",
"2013-06-27 01:01:00",
"2013-07-07 01:01:00",
"2013-07-17 01:01:00",
"2013-07-27 01:01:00",
"2013-08-06 01:01:00",
"2013-08-16 01:01:00",
"2013-08-26 01:01:00",
"2013-09-05 01:01:00",
"2013-09-15 01:01:00",
"2013-09-25 01:01:00",
"2013-10-05 01:01:00",
]

start = datetime.datetime(2012, 10, 10, 1, 1)
stop = datetime.datetime(2013, 10, 10, 1, 1)
step = datetime.timedelta(days=10)
drange_generator = glitch.drange(start, stop, step)
assert(type(drange_generator) == types.GeneratorType)
for i, d in enumerate(drange_generator):
assert(str(d) == expected[i])
assert(i+1 == len(expected))

if __name__ == "__main__":
test_drange()
4 changes: 4 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pytest
pytest-cov
python-coveralls
sh

0 comments on commit 02af7c5

Please sign in to comment.